Skip to content
Prev 295982 / 398503 Next

trouble automating formula edits when log or * are present; update trouble

Paul et. al:

I think Gabor's incantation qualifies as my desired alternative to
eval(parse())). It is, unfortunately, rather tricky, imo.

However, the objection you raise to the gsub(deparse()) solution is
easily overcome through the use of an appopriate regex: e.g.:

 gsub("\\<x\\>","log(x)","x+xc+cx")
[1] "log(x)+xc+cx"

See the ?regex documentation on \< and \> . I believe this allows this
simple approach to handle all cases -- am I wrong about this?

Incidentally, I need to note that I was **wrong** in my previous statement that
formula(lm(y!x1))  does not work. It works fine, as there is a formula
method for (g)lm . I should look before I leap.

-- Bert
On Tue, May 29, 2012 at 10:41 AM, Paul Johnson <pauljohn32 at gmail.com> wrote: