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