Hi, May be this helps: set.seed(24) mydata4<- as.data.frame(matrix(sample(1:100,10*38,replace=TRUE),ncol=38)) dim(mydata4) #[1] 10 38 library(matrixStats) res<-do.call(cbind,lapply(1:400, function(i) {permutation<-sample(mydata4); (rowMeans(permutation[,1:27])-rowMeans(permutation[,28:38]))/(rowSds(permutation[,1:27])+rowSds(permutation[,28:38]))} )) dim(res) #[1] 10 400
A.K. >I want to do permutation test and then get a PGC score 400 times on mydata4 >(microarray data) > >I use 2 functions as below: >1. permutation<-sample(mydata4) >2. PGC <- (rowMeans(permutation[ ,1:27]) - rowMeans(permutation[ ,28:38]))/ (rowSds(permutation [,1:27]) + rowSds(permutation [,28:38])) > >What should I do to repeat these 2 functions in succession for 400 times and combine (cbind?) the 400 PGC score for the 7129 genes in one file? > >Can any one help, thanks! ______________________________________________ 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.