f.monthly | R Documentation |
Use this function to create a frequency for time-series data that occurs monthly.
f.monthly(year, month)
year |
An integer representing the year of the observation. |
month |
An integer representing the month of the observation (It should be between 1 to 12). |
In order to use the as.frequency
function for this type of frequency,
you need the following information:
Character Format "#m#"
(first # is the year
, second # is
the month
(1 to 12); e.g., 2010m8 or 2010m12. Note that 2000m0 or 2000m13 are invalid.
Class Id "m"
An object of class ldtf
which is also a list with the following members:
class |
Determines the class of this frequency. |
year |
Determines the |
month |
Determines the |
m0 <- f.monthly(2020, 2)
# this is a monthly frequency that refers to the second month of the year 2020.
m0_value_str <- as.character(m0) # this will be '2020M2'.
m0_class_str <- get.class.id(m0) # this will be 'm'.
m_new <- as.frequency("2021m3", "m")
# this is a monthly frequency that refers to the third month of the year 2021.
# Don't make the following mistakes:
m_invalid <- try(f.monthly(2020, 0))
m_invalid <- try(f.monthly(2020, 5))
m_invalid <- try(as.frequency("2021m0", "m"))
m_invalid <- try(as.frequency("2021m13", "m"))
m_invalid <- try(as.frequency("2021", "m"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.