f.quarterly {tdata}R Documentation

Create a Quarterly Frequency

Description

Use this function to create a frequency for time-series data that occurs quarterly.

Usage

f.quarterly(year, quarter)

Arguments

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).

Details

In order to use the as.frequency function for this type of frequency, you need the following information:

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 year.

quarter

Determines the quarter.

Examples


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"))



[Package tdata version 0.3.0 Index]