Re: [R] rollapply.zoo() with na.rm=TRUE
On Mon, Aug 15, 2011 at 6:51 AM, Giles wrote: > Thanks for that Gabor, it works fine from the development version > you've pointed to. > > There is in addition a performance issue: the following benchmark ran > in under 0.2s in the previous version, now consistently shows elapsed > time over 14s on a Xeon with Windows. It's unaffected if I use the > development version. > > Giles Heywood > > #example > system.time(rollmax(x= zoo(1:1,1:1),k=20,align="right")) > > R version 2.13.1 (2011-07-08) > Platform: i386-pc-mingw32/i386 (32-bit) Thanks for noticing that. It should now be fixed in the development version. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@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.
Re: [R] rollapply.zoo() with na.rm=TRUE
Thanks for that Gabor, it works fine from the development version you've pointed to. There is in addition a performance issue: the following benchmark ran in under 0.2s in the previous version, now consistently shows elapsed time over 14s on a Xeon with Windows. It's unaffected if I use the development version. Giles Heywood #example system.time(rollmax(x= zoo(1:1,1:1),k=20,align="right")) R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) __ R-help@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.
Re: [R] rollapply.zoo() with na.rm=TRUE
On Fri, Aug 12, 2011 at 11:47 AM, Giles wrote: > Hi. > > I'm comparing output from rollapply.zoo, as produced by two versions > of R and package zoo. I'm illustrating with an example from a R-help > posting 'Zoo - bug ???' dated 2010-07-13. > > My question is not about the first version, or the questions raised in > that posting, because the behaviour is as documented. I'm puzzled as > to why na.rm no longer is passed to mean, i.e. why element 2 is NA and > not 1.5 when na.rm=TRUE, as it was before. > > The first example, where na.rm is not specified, and which now behaves > more as one might expect prior to carefully reading the documentation, > is also different from before. > > This is not specific to mean(), similar behaviour is shown for e.g. sum(). > > Have I misunderstood the documentation? Is there a way to reproduce > the old behaviour with na.rm=TRUE? This is a bug. Its fixed in the development version. Get the entire development version or just that one file: library(zoo) source("http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/zoo/R/rollapply.R?root=zoo";) rollapply(a, FUN = mean, width = 3, na.rm = TRUE) or use this workaround: rollapply(a, FUN = function(x) mean(x, na.rm = TRUE), width = 3) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@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] rollapply.zoo() with na.rm=TRUE
Hi. I'm comparing output from rollapply.zoo, as produced by two versions of R and package zoo. I'm illustrating with an example from a R-help posting 'Zoo - bug ???' dated 2010-07-13. My question is not about the first version, or the questions raised in that posting, because the behaviour is as documented. I'm puzzled as to why na.rm no longer is passed to mean, i.e. why element 2 is NA and not 1.5 when na.rm=TRUE, as it was before. The first example, where na.rm is not specified, and which now behaves more as one might expect prior to carefully reading the documentation, is also different from before. This is not specific to mean(), similar behaviour is shown for e.g. sum(). Have I misunderstood the documentation? Is there a way to reproduce the old behaviour with na.rm=TRUE? Thanks. Giles Version 1 -- R version 2.12.0 (2010-10-15) Platform: i386-pc-mingw32/i386 (32-bit) [27] zoo_1.6-4 > a <- zoo(c(NA,1:9),1:10) > rollapply(a,FUN=mean,width=3) 2 3 4 5 6 7 8 9 NA NA NA NA NA NA NA NA > rollapply(a,FUN=mean,width=3, na.rm = FALSE) 2 3 4 5 6 7 8 9 NA 2 3 4 5 6 7 8 > rollapply(a,FUN=mean,width=3, na.rm = TRUE) 2 3 4 5 6 7 8 9 1.5 2.0 3.0 4.0 5.0 6.0 7.0 8.0 Version 2 -- R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) [25] zoo_1.7-2 > a <- zoo(c(NA,1:9),1:10) > rollapply(a,FUN=mean,width=3) 2 3 4 5 6 7 8 9 NA 2 3 4 5 6 7 8 > rollapply(a,FUN=mean,width=3, na.rm = FALSE) 2 3 4 5 6 7 8 9 NA 2 3 4 5 6 7 8 > rollapply(a,FUN=mean,width=3, na.rm = TRUE) 2 3 4 5 6 7 8 9 NA 2 3 4 5 6 7 8 __ R-help@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.