xts() speed on data with date index
The explanation for the time difference is likely that xts converts all time indexes to POSIXct internally whereas zoo works with them in their original form. Thus the time difference would be expected to be the conversion time. Once its converted then xts would likely be faster for those xts operatoins where the xts code is in C. In contrast zoo is 100% R although eventually it is anticipated that portions of zoo will be in C too. As xts in a subclass of zoo some of its operations are done in zoo so in that case there would not be much of a difference in speed or if xts handles the corresponding operation itself but in R then it would not be expected that there would be much difference either.
On Sat, Jul 25, 2009 at 8:59 AM, michael li<michaellibeijing at gmail.com> wrote:
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
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.