yearmon | R Documentation |
These functions can be used to convert the times of "ts"
series
with frequency
of 12 or 4 or objects of "yearmon"
and
"yearqtr"
class, as defined in the "zoo" package, to
chron
dates.
## S3 method for class 'yearmon'
as.chron(x, frac = 0, holidays = FALSE, ...)
## S3 method for class 'yearqtr'
as.chron(x, frac = 0, holidays = FALSE, ...)
## S3 method for class 'ts'
as.chron(x, frac = 0, holidays = FALSE, ...)
x |
an object of class |
frac |
Number between zero and one inclusive representing the fraction of the way through the month or quarter. |
holidays |
If |
... |
Other arguments passed to |
The "yearmon"
and "yearqtr"
classes are defined in
package zoo. If holidays
is TRUE
or a vector of
dates then the is.holiday
function is used to determine whether
days are holidays.
The method for ts objects converts the times corresponding to
time(x)
to chron. The ts series must have a frequency that is
a divisor of 12.
Returns a chron
object.
is.holiday
,
ts
## Monthly time series data.
as.chron(AirPassengers)
as.chron(time(AirPassengers))
## convert to first day of the month that is not a weekend or holiday
as.chron(AirPassengers, frac = 0, holidays = TRUE)
## convert to last day of the month
as.chron(AirPassengers, frac = 1)
## convert to last day of the month that is not a weekend or holiday
as.chron(AirPassengers, frac = 1, holidays = TRUE)
## convert to last weekday of the month
as.chron(AirPassengers, frac = 1, holidays = c())
## Quarterly time series data.
as.chron(presidents)
as.chron(time(presidents))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.