Conversion S3 methods to coerce data objects of arbitrary classes to xts and back, without losing any attributes of the original format.
Usage
# S3 method for class 'Date'
as.xts(x, ...)
# S3 method for class 'POSIXt'
as.xts(x, ...)
# S3 method for class 'data.frame'
as.xts(
x,
order.by,
dateFormat = "POSIXct",
frequency = NULL,
...,
.RECLASS = FALSE
)
# S3 method for class 'irts'
as.xts(x, order.by, frequency = NULL, ..., .RECLASS = FALSE)
# S3 method for class 'matrix'
as.xts(
x,
order.by,
dateFormat = "POSIXct",
frequency = NULL,
...,
.RECLASS = FALSE
)
# S3 method for class 'timeDate'
as.xts(x, ...)
# S3 method for class 'timeSeries'
as.xts(
x,
dateFormat = "POSIXct",
FinCenter,
recordIDs,
title,
documentation,
...,
.RECLASS = FALSE
)
# S3 method for class 'ts'
as.xts(x, dateFormat, ..., .RECLASS = FALSE)
as.xts(x, ...)
xtsible(x)
# S3 method for class 'yearmon'
as.xts(x, ...)
# S3 method for class 'yearqtr'
as.xts(x, ...)
# S3 method for class 'zoo'
as.xts(x, order.by = index(x), frequency = NULL, ..., .RECLASS = FALSE)Arguments
- x
Data object to convert. See details for supported types.
- ...
Additional parameters or attributes.
- order.by, frequency
See zoo help.
- dateFormat
What class should the dates be converted to?
- .RECLASS
Should the conversion be reversible via
reclass()?- FinCenter, recordIDs, title, documentation
See timeSeries help.
Details
A simple and reliable way to convert many different objects into a uniform format for use within R.
as.xts() can convert objects of the following classes into an xts object:
object: timeSeries, ts, matrix, data.frame,
and zoo. xtsible() safely checks whether an object can be converted to
an xts object.
Additional name = value pairs may be passed to the function to be added to
the new object. A special print.xts() method ensures the attributes are
hidden from view, but will be available via R's standard attr() function,
as well as the xtsAttributes() function.
When .RECLASS = TRUE, the returned xts object internally preserves all
relevant attribute/slot data from the input x. This allows for temporary
conversion to xts in order to use zoo and xts compatible methods. See
reclass() for details.