Re: [R] running many different regressions

2009-09-20 Thread Schalk Heunis
Georg for example: >data(swiss) >data=swiss >lapply(2:length(data),function(x) lm(data[,1]~data[,x])) HTH Schalk Heunis On Sun, Sep 20, 2009 at 2:05 PM, Georg Ehret wrote: > Dear R community, > I have a dataframe with say 100 different variables. I wish to regress > variable 1 separately on

Re: [R] running many different regressions

2009-09-20 Thread John Kane
--- On Sun, 9/20/09, Wensui Liu wrote: > From: Wensui Liu > Subject: Re: [R] running many different regressions > To: "Gabor Grothendieck" > Cc: R-help@r-project.org > Received: Sunday, September 20, 2009, 3:04 PM > should chicken be blamed by the > people al

Re: [R] running many different regressions

2009-09-20 Thread Wensui Liu
should chicken be blamed by the people allergic by eggs? On Sun, Sep 20, 2009 at 3:00 PM, Gabor Grothendieck wrote: > Not everyone carefully examines the code from r-help posts > prior to pasting it in.  Posting code is very dangerous and > should not be done. > > Quite the contrary they often tr

Re: [R] running many different regressions

2009-09-20 Thread Gabor Grothendieck
Not everyone carefully examines the code from r-help posts prior to pasting it in. Posting code is very dangerous and should not be done. Quite the contrary they often try to understand the code by running it. Code like this should never be posted. On Sun, Sep 20, 2009 at 2:47 PM, Wensui Liu

Re: [R] running many different regressions

2009-09-20 Thread Wensui Liu
well, i assume you understand what my code does. please don't use if you don't know what you are using. On Sun, Sep 20, 2009 at 2:44 PM, Gabor Grothendieck wrote: > On Sun, Sep 20, 2009 at 2:38 PM, Wensui Liu wrote: >> I just quickly draft one with boston housing data. and it should be >> close

Re: [R] running many different regressions

2009-09-20 Thread Gabor Grothendieck
On Sun, Sep 20, 2009 at 2:38 PM, Wensui Liu wrote: > I just quickly draft one with boston housing data. and it should be > close to what you need. > > # REMOVE ALL OBJECTS > rm... WARNING!!! Running the code in this post could wipe out your entire workspace Please do NOT post such code. __

Re: [R] running many different regressions

2009-09-20 Thread Wensui Liu
apologize, there is a typo in the glm() :-) On Sun, Sep 20, 2009 at 2:05 PM, Georg Ehret wrote: > Dear R community, >   I have a dataframe with say 100 different variables. I wish to regress > variable 1 separately on every other variable (2-100) in a linear regression > using lm. There must be a

Re: [R] running many different regressions

2009-09-20 Thread Wensui Liu
I just quickly draft one with boston housing data. and it should be close to what you need. # REMOVE ALL OBJECTS rm(list = ls()); # DATA PREPARATION library(MASS); data(Boston); X<-I(as.matrix(Boston[-14])); Y<-I(as.matrix(Boston[14])); for(i in 1:13) { X2 <- X[, i] data <- data.frame(Y, X

[R] running many different regressions

2009-09-20 Thread Georg Ehret
Dear R community, I have a dataframe with say 100 different variables. I wish to regress variable 1 separately on every other variable (2-100) in a linear regression using lm. There must be an easy way to do this without loops, but I have difficulties figuring this out... Can you please help? Th