Re: [R] extract variables from model formula

2011-08-17 Thread Joshua Wiley
Hi Eik, Thanks, that got me on the right track. After looking at how get_all_vars() works, I am using: all.vars(as.formula(m)) which works great. Thanks again, Josh On Wed, Aug 17, 2011 at 6:14 AM, Eik Vettorazzi wrote: > Hi Josh, > I think, > > m <- lm(mpg ~ factor(cyl)+I(mpg^2), data = mt

Re: [R] extract variables from model formula

2011-08-17 Thread Eik Vettorazzi
Hi Josh, I think, m <- lm(mpg ~ factor(cyl)+I(mpg^2), data = mtcars) nd<-get_all_vars(m,data=mtcars) is what you are after. cheers. Am 17.08.2011 04:27, schrieb Joshua Wiley: > Hi All, > > I am writing a function to predict values based on a model. It works > fine as long as the formula just

[R] extract variables from model formula

2011-08-16 Thread Joshua Wiley
Hi All, I am writing a function to predict values based on a model. It works fine as long as the formula just uses regular variable names. I am having a problem when the variables are wrapped with a function call. For example: m <- lm(mpg ~ factor(cyl), data = mtcars) ## I get the column names