yearmon {zoo}R Documentation

An Index Class for Monthly Data

Description

"yearmon" is a class for representing monthly data.

Usage

yearmon(x)

Arguments

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

Details

The yearmon class is used to represent monthly data. Internally it holds the data as year plus 0 for January, 1/12 for February, 2/12 for March and so on in order that its internal representation is the same as ts class with frequency = 12. If x is not in this format it is rounded via floor(12*x + .0001)/12.

There are coercion methods available for various classes including: default coercion to "yearmon" (which coerces to "numeric" first) and coercion from "yearmon" to "Date" (see below), "POSIXct", "POSIXlt", "numeric", "character".

Value

Returns its argument converted to class yearmon.

See Also

yearqtr, zoo, zooreg, ts

Examples

x <- yearmon(2000 + seq(0, 23)/12)
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(24), x, frequency = 12)
z
as.ts(z)

[Package zoo version 1.0-5 Index]