[R] Find and remove matching parentheses

Dieter Menne dieter.menne at menne-biomed.de
Sun Apr 2 16:19:34 CEST 2006


To create a more end-user readable table captions for modeld, I would like
to get rid of the I(...) construct in formulae ("what's the hell does the
I(..) mean in the contrast table")

Example:

effect ~ I(sqrt(nitro))*treat + I(nitro^2)

should giv

effect ~ sqrt(nitro)*treat + nitro^2

In know, this is a dumb model, just my test case. As far I remember, finding
matching parentheses is nasty in regexp, so I resorted to a loop and
counting opening/closing.

Is there a more elegant solution?

Dieter




More information about the R-help mailing list