[R] Calling a column from a matrix using a variable

rgm robinmunshaw at gmail.com
Thu Mar 8 20:42:50 CET 2012

Hi there,
I'm having some difficulty using a variable to call a column from a matrix.
I am trying to analyze several columns against each other using a for loop
in the following way:


for( i in 1:length(titles)){

So that I get a list of the r-squared values for a regression of column D
against all the other columns individually.
However, I can't figure out how to insert the changing value for y into the
lm(x$D~x$"y") function without the command trying to call "column y" from
the matrix.

Thanks for any help!

View this message in context: http://r.789695.n4.nabble.com/Calling-a-column-from-a-matrix-using-a-variable-tp4457466p4457466.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list