Re: [R] rollapply.zoo() with na.rm=TRUE

2011-08-15 Thread Giles
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

2011-08-15 Thread Gabor Grothendieck
On Mon, Aug 15, 2011 at 6:51 AM, Giles giles.heyw...@amberalpha.com 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

2011-08-12 Thread Gabor Grothendieck
On Fri, Aug 12, 2011 at 11:47 AM, Giles giles.heyw...@cantab.net 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.