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
>
>______________________________________________
>R-help at stat.math.ethz.ch 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