Learn R Programming

xts (version 0.0-6)

as.xts: Convert Object To And From Class xts

Description

Conversion functions to coerce data objects of arbitrary classes to class xts and back, without losing any attributes of the original format.

Usage

as.xts(x, ...)

reclass(x)

Arguments

x
data object to convert. See details for supported types
...
additional parameters or attributes

Value

  • An S3 object of class xts.

Details

A simple and reliable way to convert many different objects into a uniform format for use within R.

It is possible with a call to as.xts to convert objects of class timeSeries, ts, its, matrix, data.frame, and zoo.

The help file as.xts.methods lists all available xts methods and arguments specific to each coercible type.

Additional name=value pairs may be passed to the function to be added to the new object. A special print.xts method will assure that the attributes are hidden from view, but will be available via R's standard attr function.

The returned object will preserve all relevant attribute/slot data within itself, allowing for temporary conversion to use zoo and xts compatible methods. A call to reclass returns the object to its original class, with all original attributes intact - unless otherwise changed.

It should be obvious, but any attributes added via the ...argument will not be carried back to the original data object, as there would be no available storage slot/attribute.

See Also

xts,as.xts.methods