Lists are the answer.
LIST<-list() for(i in 1:ncol(results6)) { LIST[[i]]<-lm(results6[,i]~data$observed) } You'll now have a 91 entry list of lm(). You can then do something like this: LIST2<-list() for(i in 1:length(LIST)) { LIST2[[i]]<-LIST[[i]]$r.squared } This should now be a list of 91 R-squared, which you can unlist() and save in matrix form if you want. ----- ---- Isaac Research Assistant Quantitative Finance Faculty, UTS -- View this message in context: http://r.789695.n4.nabble.com/Accomplishing-a-loop-on-multiple-columns-tp4284974p4285136.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.