f.multi.weekly {tdata} | R Documentation |
Create a Multi-Week Frequency
Description
Use this function to create a frequency for time-series data that occurs every 'k' weeks. The first day of the first week is used as the reference.
Usage
f.multi.weekly(date, k)
Arguments
date |
The date, which can be a list with |
k |
The number of weeks. |
Details
To use the as.frequency
function for this type of frequency,
you need the following information:
-
Character Format The first day of the first week in
"YYYYMMDD"
format. -
Class Id
"w#"
(the number is the value ofk
; e.g., w3 means every 3 weeks)
Value
An object of class ldtf
, which is also a list with the following members:
class |
The class of this frequency. |
year |
The |
month |
The |
day |
The |
k |
The value of |
Examples
mw0 <- f.multi.weekly(c(2023, 1, 2), 3)
# This is 2/1/2023, which is Monday. The next observation belongs to 23/1/2023.
mw0_value_str <- as.character(mw0) # This will be '20230102'.
mw0_class_str <- get.class.id(mw0) # This will be 'w3'.
mw_new <- as.frequency("20230109", "w4") # This is 9/1/2023.
# Don't use invalid or unsupported dates:
mw_invalid <- try(as.frequency("1399109", "w4")) # this is a too old date and unsupported
mw_invalid <- try(as.frequency("20230132", "w5")) # invalid day in month
mw_invalid <- try(as.frequency("20231331", "w2")) # invalid month
mw_invalid <- try(as.frequency("20231012", "w0"))