[The new version of gregmisc will be showing up on CRAN shortly.] -----Original Message----- From: Warnes, Gregory R Sent: Friday, March 26, 2004 6:07 PM To: 'Sean Davis' Subject: RE: Quick "running" question
Hi Sean, Congratulations, you found a bug! My "running" function took an improper shortcut. When allow.fewer=FALSE it was still passing shorter lists of elements to the called function, and then overwriting the results for the shorter lists with NAs. I've now corrected the code to skip evaluation of the function on lists shorter than the specified length when allow.fewer=FALSE. I'm attaching the latest version of the gregmisc package with the corrected code. I've also added a couple of other features while I was mucking about... -Greg > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Don MacQueen > Sent: Friday, March 26, 2004 10:58 AM > To: Sean Davis; r-help > Subject: Re: [R] Gregmisc 'running' question > > > It says "not enough x observations". That's pretty clear. > So ask yourself, what is the minimum number of observations one needs > to do a t test? > > Try this to see how many observations t.test was given each time. > > running(dat,width=50,fun=function(x) length(x),allow=T) > > or this > running(dat,width=50,fun=function(x) cat('x:',x,'\n\n'),allow=T) > > -Don > > At 9:31 AM -0500 3/26/04, Sean Davis wrote: > >Just a quick and probably simple question: > > > >> dat <- rnorm(500,sd=1+(1:500)/500) > >> fun <- function(x) t.test(x)$p.value > >> running(dat,width=50,fun=fun,allow=T) > >Error in t.test.default(x) : not enough x observations > >> running(dat,width=50,fun=fun,allow=F) > >Error in t.test.default(x) : not enough x observations > >> fun2 <- function(x) mean(x) > >> running(dat,width=50,fun=fun2,allow=T) > > 1:1 1:2 1:3 1:4 1:5 > >1:6 > >-0.334134613 -0.626595581 -0.368967457 -0.113737178 -0.057448771 > >0.228643936 > > 1:7 1:8 1:9 1:10 1:11 > >1:12 > >-0.058807689 0.021762463 -0.063805657 0.031931121 0.080465708 > >0.087062800 > >.... > > > >However, this works fine. > > > >> t.test(dat[1:50])$p.value > >[1] 0.1661845 > > > >Why doesn't t.test work with running here? > > > >Thanks, > >Sean > > > >______________________________________________ > >[EMAIL PROTECTED] mailing list > >https://www.stat.math.ethz.ch/mailman/listinfo/r-help > >PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > -- > -------------------------------------- > Don MacQueen > Environmental Protection Department > Lawrence Livermore National Laboratory > Livermore, CA, USA > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}} ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html