[R] Calculate the latest Z-score of all zoo time series

thierrydb thierrydb at gmail.com
Tue Jul 26 15:48:21 CEST 2011


Hello,

I have a population of 2000+ zoo time series (but my environment also
contains objects that are not zoo time series). I'm trying to calculate the
latest 90 days Z-Score of all zoo time series, using the following code:


LZS<-function(ser) {
temp<-window(ser,start=Sys.Date()-90)
last((temp-mean(temp))/sd(temp))
}

sapply(ls(), LZS )


The LZS function works on individual zoo time series, but not when I try to
use sapply to do it on the whole objects list. I guess this has to do with
the fact that not all objects are zoo. How can I do this correctly?


Many thanks,


TDB



--
View this message in context: http://r.789695.n4.nabble.com/Calculate-the-latest-Z-score-of-all-zoo-time-series-tp3695820p3695820.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list