Skip to content
Prev 314176 / 398506 Next

for loop not working

HI Eliza,

Try this:
set.seed(15)
mat1<-matrix(sample(1:2000,1776,replace=TRUE),ncol=444)
colnames(mat1)<-paste("Col",1:444,sep="")
res1<-lapply(1:37,function(i) mat1[,seq(i,444,37)])
res2<-lapply(1:37,function(i) {a<-mat1[,i:444];a[,c(TRUE,rep(FALSE,36))]}) #your code
identical(res1,res2)
#[1] TRUE