yearqtr {zoo}R Documentation

An Index Class for Quaterly Data

Description

"yearqtr" is a class for representing quaterly data.

Usage

yearqtr(x)

Arguments

x numeric (interpreted as being “in years”).

Details

The yearqtr class is used to represent quaterly 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.

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

Value

Returns its argument converted to class yearqtr.

See Also

yearmon, zoo, zooreg, ts

Examples

x <- yearqtr(2000 + seq(0, 7)/4)
x

# returned Date is the fraction of the way through
# the period given by frac (= 0 by default)
as.Date(x)
as.Date(x, frac = 1)
as.POSIXct(x)

z <- zoo(rnorm(8), x, frequency = 4)
z
as.ts(z)

[Package zoo version 1.0-5 Index]