Hello,


dadrivr wrote
> 
> Hi,
> 
> I have a string that I want to use in a variable call.  How can I remove
> the quotes and/or the string properties of the string to use it in a
> variable call?
> 
> Here's an example:
> 
> library(nlme)
> fm2 <- lme(distance ~ age, data = Orthodont, random = ~ 1)
> summary(fm2)
> 
> I want to update the above regression to include new predictors according
> to what is in a string:
> 
> predictors <- "age + Sex"
> update(fm2,fixed=distance ~ age + Sex) #this works
> update(fm2,fixed=distance ~ noquote(predictors)) #this doesn't work
> 
> Any help would be greatly appreciated.  Thanks!
> 

Try

response <- "distance"
predictors <- "age + Sex"
fmla.text <- paste(response, predictors, sep="~")

update(fm2,fixed=as.formula(fmla.text))

Hope this helps,

Rui Barradas



--
View this message in context: 
http://r.789695.n4.nabble.com/Remove-quotes-from-a-string-to-use-in-a-variable-call-tp4489370p4490120.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to