dw0 <- f.daily.in.week(c(2023, 5, 16), "mon", "fri") # This is 16/5/2023.
dw0_value_str <- as.character(dw0) # this will be '20230516'.
dw0_class_str <- get.class.id(dw0) # this will be 'i:mon-fri'.
# Let's use the same date with another week definition:
dw1 <- f.daily.in.week(c(2023, 5, 16), "wed", "sat")
# This is NOT 16/5/2023. It is 17/5/2023.
# Since it was outside the week, we moved it forward.
dw2 <- f.daily.in.week(c(2023, 5, 16), "wed", "sat", FALSE)
# This is 13/5/2023. The original day was outside the
# week, but we moved backward too the end of
# the previous week (which is Saturday).
dw_new <- as.frequency("20230519", "i:sat-wed")
# This is 20/1/2023 (by default, it moves forward).
# Don't use invalid or unsupported dates:
# \donttest{
dw_invalid <- try(as.frequency("1399109", "d3")) # this is a too old date and unsupported
dw_invalid <- try(as.frequency("20230132", "d4")) # invalid day in month
dw_invalid <- try(as.frequency("20231331", "d5")) # invalid month
# don't use invalid week definitions:
dw_invalid <- try(f.daily.in.week(c(2023, 5, 16), "Wednesday", "sat"))
# }
Run the code above in your browser using DataLab