Adrian Baddeley <[EMAIL PROTECTED]> writes:

> gReetings,
> 
> 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
~~~~~~~~~~ - ([EMAIL PROTECTED])             FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to