expand_dates {LTASR} | R Documentation |
Expand data through range of date values
Description
Expand a data.frame to include all dates between a start and end value defined by parameters x and y
Usage
expand_dates(
df,
start,
end,
md_tmplt = seq(as.Date("1/1/2015", "%m/%d/%Y"), as.Date("12/31/2015",
"%m/%d/%Y"), by = "day")
)
Arguments
df |
Input data.frame |
start |
start date |
end |
end date |
md_tmplt |
Date vector that defines which dates within a year to output. |
Value
A data.frame/tibble containing all variables of the input data.frame
as well as a new variable, date
, with repeated rows for each date between
start
and end
spaced as defined by md_tmplt.
Examples
library(LTASR)
data <- data.frame(id = 1,
start = as.Date('3/1/2015', format='%m/%d/%Y'),
end = as.Date('3/15/2015', format='%m/%d/%Y'))
expand_dates(data, start, end)
[Package LTASR version 0.1.3 Index]