| compose_date_parts | R Documentation |
Real-world tables often split the period across columns (a Year column
plus a Quarter or Month column, sometimes plus a Day column) rather than
carrying one parseable date. This assembles those into a single Date
and reports the finest granularity present, so the caller can aggregate
at that level (Year+Quarter -> quarterly, Year+Month -> monthly, and so
on) instead of guessing.
compose_date_parts(
df,
year_col,
quarter_col = NULL,
month_col = NULL,
day_col = NULL
)
df |
A data frame containing the part columns. |
year_col |
Character scalar, the Year column's name. Required. |
quarter_col |
Optional character scalar, a Quarter column (accepts
|
month_col |
Optional character scalar, a Month column (accepts
|
day_col |
Optional character scalar, a Day-of-month column. Only
meaningful alongside |
A list with ds (a Date vector) and granularity (one of
"year", "quarter", "month", "day", the finest part supplied).
df <- data.frame(Year = c(2023, 2023, 2024), Month = c("Jan", "Feb", "Jan"))
compose_date_parts(df, year_col = "Year", month_col = "Month")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.