f.quarterly | R Documentation |
Use this function to create a frequency for time-series data that occurs quarterly.
f.quarterly(year, quarter)
year |
An integer representing the year of the observation. |
quarter |
An integer representing the quarter of the observation (It should be between 1 and 4). |
In order to use the as.frequency
function for this type of frequency,
you need the following information:
Character Format "#q#"
(first '#' is the year
, second '#' is the
quarter
; e.g., 2010q3 or 2010q4. Note that 2000q0 or 2000q5 are invalid.
Class Id "q"
An object of class ldtf
which is also a list with the following members:
class |
Determines the class of this frequency. |
year |
Determines the |
quarter |
Determines the |
q0 <- f.quarterly(2020, 2)
# this is a quarterly frequency that refers to the second quarter of the year 2021.
q0_value_str <- as.character(q0) # this will be '2020Q2'.
q0_class_str <- get.class.id(q0) # this will be 'q'.
q_new <- as.frequency("2021q3", "q")
# this is a quarterly frequency that refers to the third quarter of the year 2021.
# Don't make the following mistakes:
q_invalid <- try(f.quarterly(2020, 0))
q_invalid <- try(f.quarterly(2020, 5))
q_invalid <- try(as.frequency("2021q0", "q"))
q_invalid <- try(as.frequency("2021q5", "q"))
q_invalid <- try(as.frequency("2021", "q"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.