The main accessor methods to an xts
object's index
is via the index
and index<-
replacement method.
The structure of the index internally is now a numeric
value corresponding to seconds since the epoch (POSIXct converted to numeric).
This change allows for near native-speed matrix subsetting, as
well as nearly instantaneous speed subsets by time.
A call to index
translates to the desired class on-the-fly.
The desired index class is stored as an attribute within the
xts object. Upon a standard index
call, this is used
to convert the numeric value to the desired class.
It is possible to view and set the class of the time-index
of a given xts
object via the indexClass
function.
To retrieve the raw numeric data a new accessor function (and replacement) has been
added .index
. This is primarily for internal use, but may be useful for
end-users.
.indexXXX
functions are useful to extract time
components of the underlying time index. The ‘indexClass’
is virtual, and as such suitable conversions are made depending
on the component requested.
The specified value for
indexClass<-
must be a character string containing
one of the following: Date
, POSIXct
,
chron
, yearmon
, yearqtr
or timeDate
.
indexFormat
only manages the manner in which the object
is displayed via print
(also called automatically
when the object is returned) and in conversion to other
classes such as matrix
. The valid values
for indexFormat are the same for format.POSIXct
,
as this is the function that does the conversion internally.
convertIndex
returns a modified xts
object, and
does not alter the original.
Changing the index type may alter the behavior of xts
functions expecting a different index, as well as the functionality
of additional methods. Use with caution.