Hi everyone, Is there a way to perform a rollapply operation on a time series data matrix and preserve the time frame? Currently, when I apply rollapply in its standart form, the date column is no longer present in the o/p matrix. Thanks, rcoder -- View this message in context: http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18694735.html Sent from the R help mailing list archive at Nabble.com.
rcoder wrote:> > Hi everyone, > > Is there a way to perform a rollapply operation on a time series data > matrix and preserve the time frame? Currently, when I apply rollapply in > its standart form, the date column is no longer present in the o/p matrix. > > Thanks, > > rcoder >-- View this message in context: http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18699707.html Sent from the R help mailing list archive at Nabble.com.
rollapply along an index: library(zoo) z <- zoo(matrix(101:110, 5), 201:205) tt <- time(z) zz <- zoo(seq_along(tt), tt) out <- rollapply(zz, 3, function(ix) list(z[ix,])) str(out) # list of zoo objects On Mon, Jul 28, 2008 at 5:03 PM, rcoder <mpdotbook at gmail.com> wrote:> > > rcoder wrote: >> >> Hi everyone, >> >> Is there a way to perform a rollapply operation on a time series data >> matrix and preserve the time frame? Currently, when I apply rollapply in >> its standart form, the date column is no longer present in the o/p matrix. >> >> Thanks, >> >> rcoder >> > > -- > View this message in context: http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18699707.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >
And then lapply over out. On Mon, Jul 28, 2008 at 6:41 PM, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:> rollapply along an index: > > library(zoo) > z <- zoo(matrix(101:110, 5), 201:205) > tt <- time(z) > zz <- zoo(seq_along(tt), tt) > out <- rollapply(zz, 3, function(ix) list(z[ix,])) > str(out) # list of zoo objects > > > On Mon, Jul 28, 2008 at 5:03 PM, rcoder <mpdotbook at gmail.com> wrote: >> >> >> rcoder wrote: >>> >>> Hi everyone, >>> >>> Is there a way to perform a rollapply operation on a time series data >>> matrix and preserve the time frame? Currently, when I apply rollapply in >>> its standart form, the date column is no longer present in the o/p matrix. >>> >>> Thanks, >>> >>> rcoder >>> >> >> -- >> View this message in context: http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18699707.html >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> 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. >> >
Hi Gabor, Thanks for your reply. Assuming I have a time series that is ready made (i.e. not constructed it using a zoo function) will the procedure below still retain the dates in the matrix? Thanks, rcoder quote author="Gabor Grothendieck"> rollapply along an index: library(zoo) z <- zoo(matrix(101:110, 5), 201:205) tt <- time(z) zz <- zoo(seq_along(tt), tt) out <- rollapply(zz, 3, function(ix) list(z[ix,])) str(out) # list of zoo objects On Mon, Jul 28, 2008 at 5:03 PM, rcoder <mpdotbook at gmail.com> wrote:> > > rcoder wrote: >> >> Hi everyone, >> >> Is there a way to perform a rollapply operation on a time series data >> matrix and preserve the time frame? Currently, when I apply rollapply in >> its standart form, the date column is no longer present in the o/p >> matrix. >> >> Thanks, >> >> rcoder >> > > -- > View this message in context: > http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18699707.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >______________________________________________ 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. -- View this message in context: http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18721849.html Sent from the R help mailing list archive at Nabble.com.
methods(rollapply) shows which classes have rollapply methods. On Tue, Jul 29, 2008 at 5:48 PM, rcoder <mpdotbook at gmail.com> wrote:> > Hi Gabor, > > Thanks for your reply. Assuming I have a time series that is ready made > (i.e. not constructed it using a zoo function) will the procedure below > still retain the dates in the matrix? > > Thanks, > > rcoder > > quote author="Gabor Grothendieck"> > rollapply along an index: > > library(zoo) > z <- zoo(matrix(101:110, 5), 201:205) > tt <- time(z) > zz <- zoo(seq_along(tt), tt) > out <- rollapply(zz, 3, function(ix) list(z[ix,])) > str(out) # list of zoo objects > > > On Mon, Jul 28, 2008 at 5:03 PM, rcoder <mpdotbook at gmail.com> wrote: >> >> >> rcoder wrote: >>> >>> Hi everyone, >>> >>> Is there a way to perform a rollapply operation on a time series data >>> matrix and preserve the time frame? Currently, when I apply rollapply in >>> its standart form, the date column is no longer present in the o/p >>> matrix. >>> >>> Thanks, >>> >>> rcoder >>> >> >> -- >> View this message in context: >> http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18699707.html >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> 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. >> > > ______________________________________________ > 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. > > > > -- > View this message in context: http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18721849.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >