extractDateFeatures: Extract Date Features from a data.frame or data.table

Description Usage Arguments Value Examples

View source: R/featureEngineering.R

Description

This function is used to construct new date features by decomposing the elements of a date/time. Currently it supports decomposing second, minute, hour, day, week day, week number, month, year, day in year, season, part of day, financial year. It is designed to be flexible via the use of functions being passed into the function. So if there is a requirement to calculate the dates differently, these can be plugged in via user-defined functions without the need to change the function.

Usage

1
2
3
4
5
extractDateFeatures(d, features = NULL, exclude = NULL,
  remove.original = FALSE, decompose = c("second", "minute", "hour", "day",
  "wday", "week", "month", "year", "yday", "season", "partofday", "fyear"),
  season = getSeasonFromDate, partofday = getPartOfDayFromDate,
  fyear = getFinancialYearFromDate)

Arguments

d

A data.frame or data.table containing the data set.

features

A character vector containing a list of features to process. If left NULL, will choose ALL the date fields within the data set. Can optionally use regular expression matching to derive the list of features by prepending it with a ~ (refer to Examples).

decompose

A character vector containing the list of features to decompose within the date.

Value

A data.frame or data.table containing an augmented list of processed decomposed date features.

Examples

1
2
3
sample.df <- data.frame(ID = runif(100, 0, 10000), EFF_DATE = Sys.time() + runif(100, 0, 24*60*60*100), EFF_TO = Sys.time() + runif(100, 24*60*60*100+1, 24*60*60*1000))
sample.extract <- extractDateFeatures(sample.df) # All date features get decomposed with all the attributes
sample.extract <- extractDateFeatures(sample.df, features = "~*DATE", decompose = c("season","partofday","fyear"))

ivanliu1989/RQuant documentation built on Sept. 13, 2019, 11:53 a.m.