What is the default native index class for an xts object?

I convert an object to xts, I don’t know which index class I should choose. I'm trying to figure out which index class the system will choose by default, I type

class(index(as.xts(sample_matrix)))
[1] "POSIXct" "POSIXt"

Which one is the standard (native) index class of the xts object? How can an object belong to two types of classes at the same time?

+3
source share
1 answer

An object can belong to several classes. Note that xts objects are inherited from the zoo, so xts objects themselves have several classes.

> class(as.xts(sample_matrix))
[1] "xts" "zoo"

POSIXct - xts. POSIXt - , POSIXct, POSIXlt, .

> s <- Sys.time()
> class(s)
[1] "POSIXct" "POSIXt"
> s - as.POSIXlt(s)
Time difference of 0 secs

POSIXct POSIXlt POSIXt, :

> s - as.Date(s)
[1] "2014-02-26 03:01:54 CST"
Warning message:
Incompatible methods ("-.POSIXt", "-.Date") for "-"

?POSIXt.

+4

All Articles