[R] Isn't aggreate.zoo supposed to work with POSIXct (zoo/TTR/xts issue)?

Achim Zeileis Achim.Zeileis at uibk.ac.at
Mon May 17 23:43:13 CEST 2010


On Mon, 17 May 2010, ivan popivanov wrote:

>
> library(xts)
> library(TTR)
>
> ndx = getYahooData("^NDX")
> aa = ndx$Close
> bb = aggregate(aa, as.yearweek, tail, 1)
>
> The last operation takes forever, and then the bb dates are messed up.

The problem is problem due to the as.yearweek() function which is neither 
part of "zoo" nor "xts" (nor any other package I can think of).
Z

> The following produces the desired result:
>
> time(aa) = as.Date(time(aa))
> bb = aggregate(aa, as.yearweek, tail, 1)
>
> The index of ndx and aa is of POSIXct (as reported by is(time(ndx))) , which apparently causes problems. Isn't zoo (and xts) supposed to work properly regardless of the type of index? Is this a bug in one of the libraries?
>
> Thanks in advance,
> Ivan
>
> _________________________________________________________________
> 30 days of prizes: Hotmail makes your day easier! Enter Now.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list