x: either a vector of class 'Date', or coercible to date using as.Date, or a data frame / list with a date variable in the first column.
gen: character. A vector of identifiers to generate from x. The possible identifiers are found in .Tvars. The default setting is to generate all identifiers apart from "Day".
origin: character / Date. Passed to as.Date: for converting numeric x to date.
keep.date: logical. TRUE will keep the date variable in the first column of the resulting dataset, FALSE will remove the date variable in favor of the generated identifiers.
remove.missing.date: logical. TRUE will remove missing values in x. If x is a dataset, the corresponding rows will be removed.
sort: logical. TRUE will sort the data by the date column.
as.factor: TRUE will generate quarters, fiscal years and months ('Quarter', 'FY', 'QFY', 'Month') as factor variables. It is also possible to use as.factor = "ordered" to generate ordered factors. FALSE will generate fiscal years as character and quarters and months as integer variables.
...: not used.
Returns
A data.table containing the computed identifiers as columns. See Examples.
Examples
# First a basic examplex <- seq.Date(as.Date("1999-01-01"), as.Date("2000-01-01"), by ="month")expand_date(x)expand_date(x, gen = c("Year","Month"), keep.date =FALSE)# Now using the APIexpand_date(get_data("BOU_CPI"))# Getting Monthly CPI data from the Bank of Uganda# Same thingget_data("BOU_CPI", expand.date =TRUE)