Yep that's where I am now

When I try

getSymbols('AAPL')
closes = Cl(AAPL)
change = rollapply(closes['2010-02-25::'],width=2, function(x) { log(x[2]/x[1])}, by=1, align = "right", na.pad = TRUE)

I end up with

Error in switch(deparse(substitute(FUN)), mean = return(rollmean(data,  : 
  switch: EXPR must return a length 1 vector

this was what I expected

rollapply(zoo(1:10), 2, sum, na.pad = TRUE, by = 1, align="right")
 1  2  3  4  5  6  7  8  9 10 
NA  3  5  7  9 11 13 15 17 19

On Mar 5, 2010, at 9:17 PM, Judson m wrote:

> > Here was a naive attempt to do standard deviation with sliding window
> >>require(quantmod)
> >>getSymbols("AAPL")
> >> AAPL$STDDEV = sd(Cl(AAPL), 20)
> >> AAPL$SMA = SMA(Cl(AAPL), 10)
> >> AAPL
> 
> I am pretty sure that rollapply in the ZOO library would work for you. 
> 
> 


	[[alternative HTML version deleted]]

