vars_to_date | R Documentation |
Multiple variables to unique date variable
vars_to_date(
tbl,
year = NULL,
quarter = NULL,
month = NULL,
day = NULL,
date = NULL,
drop_vars = TRUE,
clean_names = FALSE,
date_format = "%d-%m-%y",
origin = "1900-01-01",
.round = c("end", "middle", "start")
)
tbl |
data.frame or tbl connection |
year |
year variable position or name |
quarter |
quarter variable position or name |
month |
month variable position or name |
day |
day variable position or name |
date |
a variable name or position containing a like date format |
drop_vars |
indicates if variables should be dropped |
clean_names |
indicates if all variable names should be cleaned |
date_format |
actual date format of variable in |
origin |
base date for variable convertion to date |
.round |
indicates if the date should be rounded to the end, middle or start of the period |
tbl a new data.frame with the compute variable
tbl <- data.frame(
year = rep("2021", 12),
month = month.name,
day = sample(1:3, 12, TRUE),
value = sample(100:1000, 12, TRUE)
)
tbl
vars_to_date(tbl, year = 1, month = 2, day = 3)
# and supports various frequencies and date formats
tbl <- data.frame(
year = rep("2021", 12),
quarter = sample(
c(
"Enero-Marzo",
"Abril-Junio",
"Julio-Septiembre",
"Octubre-Diciembre"
),
12,
TRUE
),
value = sample(100:1000, 12, TRUE)
)
tbl
vars_to_date(tbl, year = 1, quarter = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.