f.multi.yearly | R Documentation |
Use this function to create a frequency for time-series data that occurs every z
years.
f.multi.yearly(year, z)
year |
An integer representing the year of the observation. |
z |
An integer representing the number of years. It should be larger than zero. |
In order to use the as.frequency
function for this type of frequency,
you need the following information:
Character Format "#"
(the number is the year
, which means the string representation is the first year of the interval)
Class Id "z#"
('#' represents the value: z
; e.g., z3 means every 3 years)
An object of class ldtf
which is also a list with the following members:
class |
Determines the class of this frequency. |
year |
Determines the |
z |
Determines the value: |
my0 <- f.multi.yearly(2020, 2)
# this is a multi-year frequency that refers to the year 2020.
# The next observation is expected in 2022 (not the next year).
my0_value_str <- as.character(my0) # this will be '2020'.
my0_class_str <- get.class.id(my0) # this will be 'z2'.
my_new <- as.frequency("2020", "z3")
# this is a multi-year frequency that refers to the year 2020.
# However, the next observation is expected in 2023.
# Don't make the following mistakes:
my_invalid <- try(f.multi.yearly(2020, 0))
my_invalid <- try(f.multi.yearly(2020, -5))
my_invalid <- try(as.frequency("2021", "z"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.