Re: [R] Get variable names from results of lm()

2012-05-23 Thread Marc Schwartz
On May 23, 2012, at 2:52 PM, arun wrote: > Hi Marc, > > Just to point out some difference, > > > x <- 1:20 > y <- x + (x/4 - 2)^3 + rnorm(20, sd=3) > names(y) <- paste("O",x,sep=".") >ww <- rep(1,20); ww[13] <- 0 > summary(lmxy <- lm(y ~ x + I(x^2)+I(x^3) + I((x-10)^2),

Re: [R] Get variable names from results of lm()

2012-05-23 Thread arun
weights = ww), cor = TRUE) > all.vars(formula(lmxy)) [1] "y" "x" > variable.names(lmxy) [1] "(Intercept)" "x"   "I(x^2)"  "I(x^3)"   A.K. - Original Message - From: Marc Schwartz To: Peter Ehlers Cc:

Re: [R] Get variable names from results of lm()

2012-05-23 Thread arun
weights = ww), cor = TRUE) variable.names(lmxy) [1] "(Intercept)" "x"   "I(x^2)"  "I(x^3)"   A.K. - Original Message - From: jdub To: r-help@r-project.org Cc: Sent: Wednesday, May 23, 2012 10:58 AM Subject:

Re: [R] Get variable names from results of lm()

2012-05-23 Thread William Dunlap
wartz > Sent: Wednesday, May 23, 2012 12:13 PM > To: Peter Ehlers > Cc: r-help@r-project.org; jdub > Subject: Re: [R] Get variable names from results of lm() > > > On May 23, 2012, at 1:42 PM, Peter Ehlers wrote: > > > On 2012-05-23 09:55, R. Michael Weylandt wrote: >

Re: [R] Get variable names from results of lm()

2012-05-23 Thread Marc Schwartz
On May 23, 2012, at 1:42 PM, Peter Ehlers wrote: > On 2012-05-23 09:55, R. Michael Weylandt wrote: >> I think the easiest that comes to mind is simply >> >> names(coef(myMod)) >> >> But did you look at myMod$terms[[3]] ? That seems to be the RHS of the >> formula input (in the few cases I tried

Re: [R] Get variable names from results of lm()

2012-05-23 Thread Peter Ehlers
On 2012-05-23 09:55, R. Michael Weylandt wrote: I think the easiest that comes to mind is simply names(coef(myMod)) But did you look at myMod$terms[[3]] ? That seems to be the RHS of the formula input (in the few cases I tried) Best, Michael It depends a bit on just what the OP wants. In cas

Re: [R] Get variable names from results of lm()

2012-05-23 Thread R. Michael Weylandt
I think the easiest that comes to mind is simply names(coef(myMod)) But did you look at myMod$terms[[3]] ? That seems to be the RHS of the formula input (in the few cases I tried) Best, Michael On Wed, May 23, 2012 at 10:58 AM, jdub wrote: > > What is the best way to get the variable names use

[R] Get variable names from results of lm()

2012-05-23 Thread jdub
What is the best way to get the variable names used in lm() from its results? Stumbling around I found I could get the response variable name from myMod$terms[[2]] but using myMod$terms[[1 ]] gives a tilda. I found the names buried in other places in the model object and in the summary of t