[R-SIG-Finance] xts() speed on data with date index

michael li michaellibeijing at gmail.com
Sat Jul 25 14:59:08 CEST 2009


I like xts because  subsetting is easier.  Something like x["2009-08"].
But it seems that xts() is a little slower than zoo() when converting
data with date index instead of time index.

> pr<-matrix(rnorm(20000),nrow=5000,ncol=4)
> t<-Sys.time()+(1:5000)*24*3600
> d<-as.Date(t)
> system.time(x<-zoo(pr,t))
   user  system elapsed
      0       0       0
> system.time(x<-zoo(pr,d))
   user  system elapsed
      0       0       0
> system.time(x<-xts(pr,t))
   user  system elapsed
      0       0       0
> system.time(x<-xts(pr,d))
   user  system elapsed
   0.34    0.00    0.35

Regards,
Michael



More information about the R-SIG-Finance mailing list