# NOT RUN {
d <- as.Date("2018-12-20") + 1:40
w <- date2week(d, week_start = "Sunday")
print(w)
# subsetting acts as normal
w[1:10]
# Combining multiple aweek objects
c(w[1], w[3], w[5])
# differing week_start days will default to the attribute of the first
# aweek object
mon <- date2week(Sys.Date(), week_start = "Monday")
mon
c(w, mon)
c(mon, w)
# combining Dates will be coerced to aweek objects under the same rules
c(w, Sys.Date())
# truncated aweek objects will be un-truncated
w2 <- date2week(d[1:5], week_start = "Monday", floor_day = TRUE)
w2
c(w[1:5], w2)
# }
Run the code above in your browser using DataLab