yearmon {zoo} | R Documentation |
"yearmon"
is a class for representing monthly data.
yearmon(x)
x |
numeric (interpreted as being “in years”). |
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"
.
Returns its argument converted to class yearmon
.
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)