yearmon {chron} | 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 "yearmon" or
"yearqtr" or "ts" objects,
or a numeric vector interpreted “in years” and fractions of
years. |
frac |
Number between zero and one inclusive representing the fraction of the way through the month or quarter. |
holidays |
If TRUE or a vector of chron dates, indicated
holidays and weekends are excluded so the return value will be a
non-holiday weekday. |
... |
Other arguments passed to chron . |
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.
## 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))