[R] Speed up computing: looping through data?
weller at erdw.ethz.ch
Tue Jul 17 19:33:28 CEST 2007
Please excuse my ignorance, but I am having difficulty with this, and am
unable to find help on the website/Google.
I have a series of explanatory variables that I am aiming to get
parsimony out of.
For example, if I have 10 variables, a-j, I am initially looking at the
linear relationships amongst them:
my.lm1 <- lm(a ~ b+c+d+e+f+g+h+i+j, data=my.data)
my.lm2 <- lm(b ~ a+c+d+e+f+g+h+i+j, data=my.data)
Instead of repeatedly typing this in, is there a way to construct a
(for) loop of some description to semi-automate this process?
In addition, I have several response variables. Instead of examining
these individually against the explanatory variables, is there a way to
'group' all response and explanatory variables and then look at all the
linear relationship amongst all these variables? I have tried:
my.group1 <- c(a,b,c,d,e,f,g,h,i,j)
my.group2 <- c(k,l,m,n,o,p,q,r,s,t)
my.lm3 <- lm(my.group1 ~ my.group2)
to no avail.
Thanks for your help, Andy
More information about the R-help