r - Access zoo or xts index -
i using zoo objects, buy question applies xts objects. looks me 1 column vector index. in case index vector of dates , 1 column vector data. except access dates (from index).
for example have following result:
objzoo <- structure(c(10, 20), .dim = c(2l, 1l), index = c(14788, 14789), class = "zoo", .dimnames = list(null, "data")) unclass(objzoo) # data # [1,] 10 # [2,] 20 # attr(,"index") # [1] 14788 14789
i want 14789
in variable or vector, i'm not sure how access it.
from ?zoo
, there 2 convenience methods access data in zoo objects:
coredata()
returns data in zoo objectindex()
returns index
for example:
x.date <- as.date("2003-02-01") + c(1, 3, 7, 9, 14) - 1 x <- zoo(rnorm(5), x.date) index(x) [1] "2003-02-01" "2003-02-03" "2003-02-07" "2003-02-09" "2003-02-14" coredata(x) [1] -1.2487943 0.8911630 1.2713133 -0.1024638 0.2989194
Comments
Post a Comment