Adrian Baddeley <email@example.com> writes:
> I want to manipulate a formula object, containing the name "."
> so that "." is replaced by a desired (arbitrary) expression.
> What is a safe way to do this?
I'm not vouching for the safety, but something along the lines of
mycall <- quote(a+b) # NOT mode "expression" substitute(~., list(.=mycall))
or (this stuff is such a pain)
eval(substitute(substitute(formula, list(.=mycall)), list=myformula))
Notice, BTW, that formulas can have "." on both sides, so you may want to do it only to either the LHS or RHS as appropriate. Also note that the substitute operations loses the the class and environment of the original, so you may need to put that back in place with as.formula and environment<-
-- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (firstname.lastname@example.org) FAX: (+45) 35327907 ______________________________________________ Remail@example.com mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlReceived on Fri Jun 03 18:08:06 2005
This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:22 EST