Xts is an extension of zoo that has some other nice features: character subsetting, periodic apply functions, good built in time conversions, etc.
More importantly for my work, the authors put a lot of work into making sure it plays well with all of R's many ts classes so I almost always start any project by changing input from any source to xts so I don't have to think about the occasional inconsistencies. If you arent working with multiple data sources and don't need the extended functionality, there's absolutely nothing wrong with zoo - it's also a great package. Michael Weylandt PS - more than anything, I was somewhat distracted when answering and couldn't get your code to work so I falsely assumed it was a zoo problem: so I just wrote an example I knew worked in xts - when I thought for a moment and saw your bug, I realized the same trick would work in zoo. On Aug 10, 2011, at 1:53 AM, Richard Ma <xuanlong...@uts.edu.au> wrote: > Hi Michael, > > Thanks for your kindly help. Problem solved! > > Just curious why you prefer "xts" rather than "zoo"? Is "xts" more powerful? > > BTW, It's my mistake that incorrectly type the code. ;-) > > Cheers, > Richard > > > R. Michael Weylandt <michael.weyla...@gmail.com> wrote: >> >> I'd suggest you look into the xts class and write >> >> require(xts) >> xts = as.xts(1:5,Sys.Date()+1:5) >> time(xts)[xts==3] >> >> By the way, your code isn't pastable for me: not sure why. >> >> Michael Weylandt >> > > > ----- > Richard Ma > PhD student, Ecology & Remote Sensing > Climate Change Cluster, Department of Environment Science > University of Technology, Sydney > http://everydropr.wordpress.com > -- > View this message in context: > http://r.789695.n4.nabble.com/How-to-get-the-date-of-specific-value-within-a-zoo-object-tp3731885p3732108.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.