[R] actually, problems with indexing

Vladimir Eremeev wl2776 at gmail.com
Mon Sep 17 20:34:38 CEST 2007




Riddle Chin wrote:
> 
> Hi, everyone:
>      R is new to me. I am writing a nested loop to simulate data for
> t-test. The following code is wrong. The subscript is out of bounds. Could
> anyone tell me how to revise it? Thanks, Riddle Chin.
>    
>   result<-matrix(ncol=5, nrow=1000)
> colnames(result)<-c('N=20','N=40','N=60','N=80','N=100')
>  for (i in 1:1000){
> 
   for (j in 1:5){
     x<-rnorm(j*20,2.7,1)

Riddle Chin wrote:
> 
>      result[i,j]<-t.test(x,mu=4)$p.value<=0.05
>    }
>  }
> 
> 

-- 
View this message in context: http://www.nabble.com/problems-with-nested-loop-tf4468945.html#a12742249
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list