View source: R/expand_variants.R
expand_dates | R Documentation |
Expand date ranges.
expand_dates( df, start_var, end_var, name = "Expanded", fmt = "%Y-%m-%d", vars_to_keep = NULL, unit = "day" )
df |
Data frame (can also be a data.table or a tibble) |
start_var |
Start Date column |
end_var |
End Date column |
name |
The name of newly created column. Defaults to 'Expanded' |
fmt |
The format of date columns, defaults to Y-M-D |
vars_to_keep |
Which columns you would like to keep |
unit |
By which unit of time you want to expand; the default is day |
Returns a full data frame with expanded sequences in a column, e.g. by day or month.
df <- data.frame( id = c("1111", "2222", "3333"), gender = c("M", "F", "F"), start = c("2018-01-01", "2019-01-01", "2020-01-01"), end = c("2018-01-05", "2019-01-07", "2020-01-08") ) expand_dates(df, start_var = "start", end_var = "end", vars_to_keep = c("id", "gender"), unit = "day")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.