f.x.times.z.years {tdata} | R Documentation |
Create an X-Times-Z-Years
Frequency
Description
Use this function to create a frequency for time-series data that occurs x
times every z
years.
Usage
f.x.times.z.years(year, x, z, position)
Arguments
year |
An integer representing the year of the observation. |
x |
An integer representing the number of partitions in each |
z |
An integer representing the number of years. It should be a positive integer. |
position |
An integer representing the position of the current observation. It should be a positive integer and cannot be larger than |
Details
In order to use the as.frequency
function for this type of frequency,
you need the following information:
-
Character Format
"#:#"
(Similar toX-Times-A-Year
. Note that the string representation refers to the first year of the interval.) -
Class Id
"x#z#"
(first '#' is the value:x
, second '#' is the value:z
; e.g., x23z4 means 23 times every 4 years)
Value
An object of class ldtf
, which is also a list with the following members:
class |
The class of this frequency. |
year |
The |
z |
The value: |
x |
The value: |
position |
The |
Examples
xtzy0 <- f.x.times.z.years(2020, 3, 2, 3)
# This frequency divides the year 2020 into 3 partitions and
# refers to the last partition. The next observation
# belongs to 2022 (not the next year).
xtzy_value_str <- as.character(xtzy0) # This will be '2020:3'.
xtzy_class_str <- get.class.id(xtzy0) # This will be 'x3z2'.
xtzy_new <- as.frequency("2021:3", "x3z4")
# This frequency divides the year 2021 into 3 partitions
# and refers to the last partition. The next observation occurs after 4 years.
# Don't make the following mistakes:
xtzy_invalid <- try(f.x.times.z.years(2020, 3, 5, 0))
xtzy_invalid <- try(f.x.times.z.years(2020, 3, 0, 1))
xtzy_invalid <- try(as.frequency("2021:25", "x24y2"))