Details
The “yearqtr” class is used to represent quarterly data. Internally it holds the data as year plus 0 for Quarter 1, 1/4 for Quarter 2 and so on in order that its internal representation is the same as ts class with frequency = 4. If x is not in this format it is rounded via floor(4*x + .0001)/4.
as.yearqtr.character uses a default format of “%Y Q%q”, “%Y q%q” or “%Y-%q” according to whichever matches. %q accepts the numbers 1-4 (possibly with leading zeros). Due to this %q does not match to single digits only and consequently formats such as as.yearqtr(“Q12000”, “Q%q%Y”) are ambiguous and do not work (i.e., result in NA).
There are coercion methods available for various classes including: default coercion to “yearqtr” (which coerces to “numeric” first) and coercion from “yearqtr” to “Date” (see below), “POSIXct”, “POSIXlt”, “numeric”, “character” and “jul”.
The last one is from the frame package on CRAN.
There is an is.numeric method which returns FALSE.
There is also a date method for as.yearqtr usable with objects created with package date.
Sys.yearqtr() returns the current year/month and methods for min, max and range are defined (by defining a method for Summary).
A yearqtr mean method is also defined.
Certain methods support a frac argument. See yearmon.