expand_date {ugatsdb} | R Documentation |
Generate Temporal Identifiers from a Date Column
Description
This function expands a date column and generates additional temporal identifiers from it (such as the year, month, quarter, fiscal year etc.).
Usage
expand_date(
x,
gen = c("Year", "Quarter", "FY", "QFY", "Month"),
origin = "1899-12-30",
keep.date = TRUE,
remove.missing.date = TRUE,
sort = TRUE,
as.factor = TRUE,
...
)
Arguments
x |
either a vector of class 'Date', or coercible to date using |
gen |
character. A vector of identifiers to generate from |
origin |
character / Date. Passed to |
keep.date |
logical. |
remove.missing.date |
logical. |
sort |
logical. |
as.factor |
|
... |
not used. |
Value
A data.table
containing the computed identifiers as columns. See Examples.
See Also
Examples
# First a basic example
x <- 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 API
expand_date(get_data("BOU_CPI")) # Getting Monthly CPI data from the Bank of Uganda
# Same thing
get_data("BOU_CPI", expand.date = TRUE)