[R] Remove quotes from a string to use in a variable call
rui1174 at sapo.pt
Tue Mar 20 20:36:34 CET 2012
> 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:
> fm2 <- lme(distance ~ age, data = Orthodont, random = ~ 1)
> 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!
response <- "distance"
predictors <- "age + Sex"
fmla.text <- paste(response, predictors, sep="~")
Hope this helps,
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.
More information about the R-help