f.x.times.a.year {tdata} | R Documentation |
Create an X-Times-A-Year
Frequency
Description
Use this function to create a frequency for time-series data that occurs x
times every year.
Usage
f.x.times.a.year(year, x, position)
Arguments
year |
An integer representing the year of the observation. |
x |
An integer representing the number of observations in each year. 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
"#:#"
(first # is theyear
and the second # is theposition
; e.g., 2010:8/12 or 2010:10/10. Note that 2000:0/2 or 2000:13/12 are invalid. -
Class Id
"y#"
(the number is the value:x
)
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 |
x |
Determines the value: |
position |
Determines the |
Examples
xty0 <- f.x.times.a.year(2020, 3, 1)
# this frequency divides the year 2020 into 3 partitions
# and refers to the first partition.
xty_value_str <- as.character(xty0) # this will be '2020:1'.
xty_class_str <- get.class.id(xty0) # this will be 'y3'.
xty_new <- as.frequency("2021:24", "z24")
# this frequency divides the year 2021 into 24 partitions
# and refers to the last partition.
# Don't make the following mistakes:
xty_invalid <- try(f.x.times.a.year(2020, 3, 0))
xty_invalid <- try(f.x.times.a.year(2020, 24, 25))
xty_invalid <- try(as.frequency("2021:13", "y12"))
xty_invalid <- try(as.frequency("2021:0", "y1"))
xty_invalid <- try(as.frequency("2021", "y1"))