# aweek objects can only be created from valid weeks:
as.aweek("2018-W10-5", week_start = 7) # works!
try(as.aweek("2018-10-5", week_start = 7)) # doesn't work :(
# you can also convert dates or datetimes
as.aweek(Sys.Date())
as.aweek(Sys.time())
# all functions get passed to date2week, so you can use any of its arguments:
as.aweek("2018-W10-5", week_start = 7, floor_day = TRUE, factor = TRUE)
as.aweek(as.Date("2018-03-09"), floor_day = TRUE, factor = TRUE)
# If you have a character vector where different elements begin on different
# days of the week, you can use the "start" argument to ensure they are
# correctly converted.
as.aweek(c(mon = "2018-W10-1", tue = "2018-W10-1"),
week_start = "Monday",
start = c("Monday", "Tuesday"))
# you can convert aweek objects to aweek objects:
x <- get_aweek()
as.aweek(x)
as.aweek(x, week_start = 7)
Run the code above in your browser using DataLab