Re: [R] How to get variable name while doing series of regressions in an automated manner?

2015-11-01 Thread Bert Gunter
Ravi et. al: My prior "solution" nagged at me, as I thought it was pretty clumsy -- I was hoping someone would show how to fix it up. As no one did, I finally realized how to do it myself. Here's how to do the iteration to get the right labeling with no pasting or formula() call by using as.name(

Re: [R] How to get variable name while doing series of regressions in an automated manner?

2015-10-27 Thread Ravi Varadhan
ail.com] Sent: Tuesday, October 27, 2015 1:50 PM To: Ravi Varadhan Cc: r-help@r-project.org Subject: Re: [R] How to get variable name while doing series of regressions in an automated manner? Marc,Ravi: I may misunderstand, but I think Marc's solution labels the list components but not nece

Re: [R] How to get variable name while doing series of regressions in an automated manner?

2015-10-27 Thread Bert Gunter
Marc,Ravi: I may misunderstand, but I think Marc's solution labels the list components but not necessarily the summary() outputs. This might be sufficient, as in: > z <- list(y1=rnorm(10,5),y2 = rnorm(10,8),x=1:10) > > ##1 > results1<-lapply(z[-3],function(y)lm(log(y)~x,data=z)) > lapply(results1

Re: [R] How to get variable name while doing series of regressions in an automated manner?

2015-10-27 Thread Marc Schwartz
> On Oct 27, 2015, at 10:19 AM, Ravi Varadhan wrote: > > Hi, > > I am running through a series of regression in a loop as follows: > > results <- vector("list", length(mydata$varnames)) > > for (i in 1:length(mydata$varnames)) { > results[[i]] <- summary(lm(log(eval(parse(text=varnames[i])))

[R] How to get variable name while doing series of regressions in an automated manner?

2015-10-27 Thread Ravi Varadhan
Hi, I am running through a series of regression in a loop as follows: results <- vector("list", length(mydata$varnames)) for (i in 1:length(mydata$varnames)) { results[[i]] <- summary(lm(log(eval(parse(text=varnames[i]))) ~ age + sex + CMV.status, data=mydata)) } Now, when I look at the result