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:
# \donttest{
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"))
# }
Run the code above in your browser using DataLab