[R-SIG-Finance] rollapply and resulting index
Brian Lee Yung Rowe
brian at muxspace.com
Sun Dec 14 15:04:31 CET 2008
Doh. Missed that in the doc. Hopefully my new glasses will address that
in the future.
Thanks,
Brian
On Sat, 2008-12-13 at 21:13 -0600, Jeff Ryan wrote:
> Hi Brain,
>
> Expected.
>
> >From ?rollapply
>
> Usage:
>
> rollapply(data, width, FUN, ..., by = 1, ascending = TRUE,
> by.column = TRUE,
> na.pad = FALSE, align = c("center", "left", "right"))
> ...
> align: character specifying whether result should be left- or
> right-aligned or centered (default).
>
> I suspect you want align='right'
>
> Jeff
>
> On Sat, Dec 13, 2008 at 8:49 PM, Brian Lee Yung Rowe <brian at muxspace.com> wrote:
> > Hi,
> >
> > I was using rollapply on a zoo time series and the resulting zoo object
> > had index values that I wasn't expecting. I assumed (for better or
> > worse) that the index dates would be anchored to the last date in the
> > index as you would expect from a rolling moving average, but instead the
> > dates seemed to hover around the median. Is this the expected behavior?
> >
> > Thanks,
> > Brian
> >
> >
> >> z <- zoo(11:15, as.Date(31:35))
> >> z
> > 1970-02-01 1970-02-02 1970-02-03 1970-02-04 1970-02-05
> > 11 12 13 14 15
> >> rollapply(z, 2, mean)
> > 1970-02-01 1970-02-02 1970-02-03 1970-02-04
> > 11.5 12.5 13.5 14.5
> >> rollapply(z, 3, mean)
> > 1970-02-02 1970-02-03 1970-02-04
> > 12 13 14
> >> rollapply(z, 4, mean)
> > 1970-02-02 1970-02-03
> > 12.5 13.5
> >> rollapply(z, 5, mean)
> > 1970-02-03
> > 13
> >
> > _______________________________________________
> > R-SIG-Finance at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only.
> > -- If you want to post, subscribe first.
> >
>
>
>
More information about the R-SIG-Finance
mailing list