[R-SIG-Finance] Subject: Re: Standard Deviations using Sliding window?
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Mar 5 19:39:30 CET 2010
On Fri, Mar 5, 2010 at 11:30 AM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> You likely want just this:
>
> diff(log(closes['2010-02-05::']))
>
> or this:
>
> rollapply(as.zoo(whatever), ...)
>
> (Actually I would have thought your command would have worked since
> your object inherits from zoo and will check it out.)
The problem seems to occur in deparsing the function. The problem has
been fixed in the devel version of zoo but in the meantime an easy
workaround is to define the function in a separate line like this:
# workaround
f <- function(x) { log(x[2]/x[1]) }
change <- rollapply(closes['2010-02-25::'], width=2, FUN = f, align =
"right", na.pad = TRUE)
More information about the R-SIG-Finance
mailing list