[R] resampling problem counting number of means above a specific value

Graham Smith myotisone at gmail.com
Sun Nov 15 18:12:46 CET 2009


I am trying to modify some code from Good 2005.

I am trying  to resample the mean of 8 values and then count how many
times the resampled mean is greater than 10. But my count of means
above 10 is coming out as zero, which I know isn't correct.

I would appreciate it if someone could look at the code below and tell
me what I am doing wrong.

Many thanks,

Graham

> LL<- c(12.5,17,12,11.5,9.5,15.5,16,14)
> N<-1000
> n<-length(LL)
> threshold<-10
> cnt<-0
> for(i in 1:N){
+ LLb <- sample (LL, n, replace=TRUE)
+ if (mean(LLb)<=threshold) cnt<-cnt+1
+ }
> cnt
[1] 0




More information about the R-help mailing list