[R] loop issues (r.squared)

andy1983 andy1983 at excite.com
Thu Feb 8 21:28:39 CET 2007


I would like to compare every column in my matrix with every other column and
get the r-squared. I have been using the following formula and loops:
summary(lm(matrix[,x]~matrix[,y]))$r.squared
where x and y are the looping column numbers

If I have 100 columns (10,000 iterations), the loops give me results in a
reasonable time.
If I try 10,000 columns, the loops take forever even if there is no formula
inside. I am guessing I can vectorize my code so that I could eliminate one
or both loops. Unfortunately, I can't figure out how to.

Any suggestions?

Thanks.
-- 
View this message in context: http://www.nabble.com/loop-issues-%28r.squared%29-tf3195843.html#a8873580
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list