Re: [R] refering to variable names in lm where the variable name is in another variable

2008-01-02 Thread John Kane
Have a look at "nam[com[1,1]]" , You're regressing against a character. Try mod<-lm(y~dat[, com[1,1]],data=dat) --- Daniel O'Shea <[EMAIL PROTECTED]> wrote: > I am trying to refer to a variable name in a lm > regression where the variable name is in another > variable, but it does seem to work

Re: [R] refering to variable names in lm where the variable name is in another variable

2007-12-30 Thread Charilaos Skiadas
On Dec 30, 2007, at 12:49 PM, Daniel O'Shea wrote: > I am trying to refer to a variable name in a lm regression where > the variable name is in another variable, but it does seem to > work. Here is an example: > > y<-rnorm(10) > dat<-data.frame(x1=rnorm(10),x2=rnorm(10),x3=rnorm(10)) > nam<-c

[R] refering to variable names in lm where the variable name is in another variable

2007-12-30 Thread Daniel O'Shea
I am trying to refer to a variable name in a lm regression where the variable name is in another variable, but it does seem to work. Here is an example: y<-rnorm(10) dat<-data.frame(x1=rnorm(10),x2=rnorm(10),x3=rnorm(10)) nam<-c('x1','x2','x3') library(gtools) com<-combinations(3,2,1:3) mod<-lm(