[R] First Variable in lm

2004-03-24 Thread Christian Hoffmann
Hi all, I just cannot think of how to do it: I want to take the first variable (column) of a data frame and regress it against all other variables. bla - function (dat) { reg - lm(whateverthefirstofthevariablenamesis ~., data=dat) return(reg) } What kind of function do I have to take

Re: [R] First Variable in lm

2004-03-24 Thread Prof Brian Ripley
On Wed, 24 Mar 2004, Christian Hoffmann wrote: Hi all, I just cannot think of how to do it: I want to take the first variable (column) of a data frame and regress it against all other variables. bla - function (dat) { reg - lm(whateverthefirstofthevariablenamesis ~., data=dat)

Re: [R] First Variable in lm

2004-03-24 Thread Gabor Grothendieck
Christian Hoffmann christian.hoffmann at wsl.ch writes: Hi all, I just cannot think of how to do it: I want to take the first variable (column) of a data frame and regress it against all other variables. bla - function (dat) { reg - lm(whateverthefirstofthevariablenamesis ~.,

RE: [R] First Variable in lm

2004-03-24 Thread Baskin, Robert
) Curious Minds Want to Know Bob -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 24, 2004 12:51 PM To: [EMAIL PROTECTED] Subject: Re: [R] First Variable in lm Christian Hoffmann christian.hoffmann at wsl.ch writes: Hi all, I just

RE: [R] First Variable in lm

2004-03-24 Thread Prof Brian Ripley
It isn't lm but terms.formula. Compare terms(dat$y ~ .,data = dat) terms(dat[, 1] ~ ., data = dat) Now as to why, exactly, see the C code in src/main/model.c. The short answer is that dat$y matches y, and dat[, 1] does not. (I am not at all sure the first is intentional.) On Wed, 24 Mar 2004,

Re: [R] First Variable in lm

2004-03-24 Thread Christian Hoffmann
I want to take the first variable (column) of a data frame and regress it against all other variables. bla - function (dat) { reg - lm(whateverthefirstofthevariablenamesis ~., data=dat) return(reg) } Thanks to all who answered my question: Prof. Brian Ripley: ---