Description Usage Arguments Details Value Author(s) See Also Examples
Conversion S3 methods to coerce data objects of
arbitrary classes to class xts
and back, without
losing any attributes of the original format.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ## S3 method for class 'xts'
as.xts(x,...,.RECLASS=FALSE)
## S3 method for class 'timeSeries'
as.xts(x, dateFormat="POSIXct", FinCenter, recordIDs,
title, documentation, ..., .RECLASS=FALSE)
## S3 method for class 'its'
as.xts(x,...,.RECLASS=FALSE)
## S3 method for class 'zoo'
as.xts(x, order.by=index(x), frequency=NULL, ..., .RECLASS=FALSE)
## S3 method for class 'ts'
as.xts(x, dateFormat,...,.RECLASS=FALSE)
## S3 method for class 'data.frame'
as.xts(x, order.by, dateFormat="POSIXct",
frequency=NULL, ...,.RECLASS=FALSE)
## S3 method for class 'matrix'
as.xts(x, order.by, dateFormat="POSIXct",
frequency=NULL, ..., .RECLASS=FALSE)
as.fts.xts(x)
|
x |
data object to convert. See details for supported types |
dateFormat |
what format should the dates be converted to |
FinCenter |
see timeSeries help |
recordIDs |
see timeSeries help |
title |
see timeSeries help |
documentation |
see timeSeries help |
order.by |
see zoo help |
frequency |
see zoo help |
... |
additional parameters or attributes |
.RECLASS |
should conversion be reversible? |
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
.
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.
If .RECLASS=TRUE, 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. This is the default
behavior when try.xts
is used for conversion, and should
not be altered by the user; i.e. don't touch it unless you are
aware of the consequences.
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.
An S3 object of class xts
.
Jeffrey A. Ryan
1 2 3 4 5 6 7 8 9 10 11 |
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Loading required package: timeDate
Attaching package: 'timeSeries'
The following object is masked from 'package:zoo':
time<-
An 'xts' object on 1970-01-01 00:00:01/1970-01-01 00:00:10 containing:
Data: int [1:10, 1] 1 2 3 4 5 6 7 8 9 10
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr "TS.1"
Indexed by objects of class: [POSIXct,POSIXt] TZ:
xts Attributes:
NULL
An 'xts' object on 1970-01-01 00:00:01/1970-01-01 00:00:10 containing:
Data: int [1:10, 1] 1 2 3 4 5 6 7 8 9 10
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr "TS.1"
Indexed by objects of class: [POSIXct,POSIXt] TZ:
xts Attributes:
NULL
An 'xts' object on 1970-01-01 00:00:01/1970-01-01 00:00:10 containing:
Data: int [1:10, 1] 1 2 3 4 5 6 7 8 9 10
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr "TS.1"
Indexed by objects of class: [POSIXct,POSIXt] TZ:
Original class: 'timeSeries'
xts Attributes:
List of 6
$ format : chr "%Y-%m-%d"
$ FinCenter : chr "GMT"
$ recordIDs :'data.frame': 0 obs. of 0 variables
$ title : chr "Time Series Object"
$ documentation: chr "Fri Jun 16 21:47:18 2017"
$ .RECLASS : logi TRUE
Time Series:
Name: object
Data Matrix:
Dimension: 10 1
Column Names: TS.1
Row Names: 1970-01-01 00:00:01 ... 1970-01-01 00:00:10
Positions:
Start: 1970-01-01 00:00:01
End: 1970-01-01 00:00:10
With:
Format: %Y-%m-%d %H:%M:%S
FinCenter: GMT
Units: TS.1
Title: Time Series Object
Documentation: Fri Jun 16 21:47:18 2017
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.