Add Dates of 1:n Days Before Given Dates

add_days_before(dates, n_days_before = 1)

Arguments

dates

vector of Date objects

n_days_before

number of days to add before the days given in dates

Examples

dates <- as.Date(c("2019-07-05", "2019-07-10")) fhpredict:::add_days_before(dates)
#> [1] "2019-07-04" "2019-07-05" "2019-07-09" "2019-07-10"
fhpredict:::add_days_before(dates, n_days_before = 2)
#> [1] "2019-07-03" "2019-07-04" "2019-07-05" "2019-07-08" "2019-07-09" #> [6] "2019-07-10"
# Duplicates are removed so that unique dates are returned fhpredict:::add_days_before(dates, n_days_before = 10)
#> [1] "2019-06-25" "2019-06-26" "2019-06-27" "2019-06-28" "2019-06-29" #> [6] "2019-06-30" "2019-07-01" "2019-07-02" "2019-07-03" "2019-07-04" #> [11] "2019-07-05" "2019-07-06" "2019-07-07" "2019-07-08" "2019-07-09" #> [16] "2019-07-10"