Re: [R] how to prevent duplications of data within a loop

2009-01-24 Thread David Freedman
or how about lm(myData$response~as.matrix(myData[2:4])) hth, david Juliet Hannah wrote: > > Hi All, > > I had posted a question on a similar topic, but I think it was not > focused. I am posting a modification that I think better accomplishes > this. > I hope this is ok, and I apologize if it

Re: [R] how to prevent duplications of data within a loop

2009-01-23 Thread Jorge Ivan Velez
Dear Juliet, Why don't you use *apply() instead a for() loop? Here is a starting point: > apply(myData[,-1],2,function(x) coefficients(lm(response~x))) var1 var2 var3 (Intercept) 0.10438369 0.10415221 0.1176728 x -0.03354243 0.02429041 -0.2240759 Note

[R] how to prevent duplications of data within a loop

2009-01-23 Thread Juliet Hannah
Hi All, I had posted a question on a similar topic, but I think it was not focused. I am posting a modification that I think better accomplishes this. I hope this is ok, and I apologize if it is not. :) I am looping through variables and running several regressions. I have reason to believe that