Hi
I'm quite new to R and I am having trouble with this code:

names(Mindreader_2012_vars)
varlist<-names(Mindreader_2012_vars)
for (i in 688:696) {
  for (j in 673:685) {
 
assign(paste("Uk_Cluster_",i-687,sep=""),cbind(get(varlist[j],pos=Mindreader_2012_vars)[get(varlist[i],
pos=Mindreader_2012_vars)>0]))
}
}

I want this code to output 9 matrixes (which are the variables 'i' is
getting) which have 13 columns (one for each of the variables that 'j' is
getting.
At the moment I get 9 matrixes with only 1 column. I guess the issue is the
way I am nesting the loops but i can't work out how to make it take all the
values of 'j' in each matrix.

Thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/R-for-loop-tp4680515.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to