Skip to content

Commit 63024eb

Browse files
authored
Merge pull request #946 from mlr-org/docs-po-date
docs: more description for datefeatures pipe op
2 parents c8fd947 + ae8e55a commit 63024eb

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

R/PipeOpDateFeatures.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
#' @format [`R6Class`][R6::R6Class] object inheriting from [`PipeOpTaskPreprocSimple`]/[`PipeOpTaskPreproc`]/[`PipeOp`].
66
#'
77
#' @description
8-
#' Based on `POSIXct`/`Date` columns of the data, a set of date related features is computed and added to
9-
#' the feature set of the output task. If no `POSIXct` or `Date` column is found, the original task is
10-
#' returned unaltered. This functionality is based on the `add_datepart()` and
11-
#' `add_cyclic_datepart()` functions from the `fastai` library. If operation on only particular
12-
#' `POSIXct`/`Date` columns is requested, use the `affect_columns` parameter inherited from
13-
#' [`PipeOpTaskPreprocSimple`].
8+
#' Based on `POSIXct`/`Date` columns of the data, a set of date related features is computed and
9+
#' added to the feature set of the output task. If no `POSIXct` or `Date` column is found, the
10+
#' original task is returned unaltered. This functionality is based on the `add_datepart()` and
11+
#' `add_cyclic_datepart()` functions from the \CRANpkg{fastai} package. If operation on only
12+
#' particular `POSIXct`/`Date` columns is requested, use the `affect_columns` parameter inherited
13+
#' from [`PipeOpTaskPreprocSimple`].
14+
#'
15+
#' For `Date` columns, the features `"hour"`, `"minute"`, `"second"`, and `"is_day"` are skipped.
1416
#'
1517
#' If `cyclic = TRUE`, cyclic features are computed for the features `"month"`, `"week_of_year"`,
1618
#' `"day_of_year"`, `"day_of_month"`, `"day_of_week"`, `"hour"`, `"minute"` and `"second"`. This
@@ -259,7 +261,7 @@ compute_cyclic_date_features = function(date_features, features, date_var) {
259261
}
260262

261263
get_weeks_per_year = function(year) {
262-
as.integer(format(as.POSIXct(paste0(year, "-12-31"), format = c("%Y-%m-%d")), "%U"))
264+
as.integer(format(as.POSIXct(paste0(year, "-12-31"), format = "%Y-%m-%d"), "%U"))
263265
}
264266

265267
is_leap_year = function(year) {

man/mlr_pipeops_datefeatures.Rd

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)