From: Gabor Grothendieck <ggrothendieck_at_gmail.com>

Date: Thu, 07 Apr 2011 19:22:44 -0400

5 5 19.0

6 7 19.8

5 5 19.0

6 7 19.8

*>
*

Date: Thu, 07 Apr 2011 19:22:44 -0400

On Thu, Apr 7, 2011 at 4:25 PM, Rita Carreira <ritacarreira_at_hotmail.com> wrote:

> Thanks so much for letting me know about the zoo package. However, I don't

*> know how to make it work very well. I was able to get the lags computed but
**> it assumes that my matrix is made up of just a long variable rather than 136
**> different variables. So, I have 270 observations, once I compute the maxima
**> of the lags, I should get a 270 x 136 matrix with blanks (NA) in the first 6
**> rows. What I actually get after using rollmax is a vector of 36,856
**> observations.
**> I also tried to run the code you gave me for BOD and I get the following
**> error:
**>
**>> BOD
**> Time demand
**> 1 1 8.3
**> 2 2 10.3
**> 3 3 19.0
**> 4 4 16.0
**> 5 5 15.6
**> 6 7 19.8
**>> testBOD <- as.data.frame(rollmax(BOD, 3, na.pad = TRUE, align = "right"))
**> Error in `[.data.frame`(x, (i - k + 1):i) : undefined columns selected
**>
**> I noticed that rollmax will work on a matrix but it does not seem to work on
**> a data frame. Am I correct?
**>
*

I must have had the development version of zoo loaded at the time. Try it with that:

*> install.packages("zoo", repos = "http://r-forge.r-project.org")
*

...various output not of interest...

> library(zoo)

*> as.data.frame(rollmax(BOD, 3, na.pad = TRUE, align = "right"))
*

Time demand

1 NA NA 2 NA NA 3 3 19.0 4 4 19.0

5 5 19.0

6 7 19.8

Alternately convert it to zoo first (this uses the CRAN version of zoo):

*> library(zoo)
**> as.data.frame(rollmax(zoo(BOD), 3, align = "right", na.pad = TRUE))
*

Time demand

1 NA NA 2 NA NA 3 3 19.0 4 4 19.0

5 5 19.0

6 7 19.8

-- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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.Received on Thu 07 Apr 2011 - 23:27:10 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Thu 07 Apr 2011 - 23:30:27 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*