f.multi.yearly {tdata} | R Documentation |
Create a Multi-Year Frequency
Description
Use this function to create a frequency for time-series data that occurs every z
years.
Usage
f.multi.yearly(year, z)
Arguments
year |
An integer representing the year of the observation. |
z |
An integer representing the number of years. It should be larger than zero. |
Details
In order to use the as.frequency
function for this type of frequency,
you need the following information:
-
Character Format
"#"
(the number is theyear
, 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)
Value
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: |
Examples
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"))
[Package tdata version 0.3.0 Index]