Suggestions for manipulating formula objects
On 4/20/05, Thomas Lumley <tlumley@u.washington.edu> wrote:
On Wed, 20 Apr 2005 rlee@fpcc.net wrote:
I'm trying to manipulate/change a formula prior to passing it to another function. A simplified example: User passes formula to my function: y~x My function does: lm(transform(y)~x) Here, transform() is added to the model's response. What is the best way to accomplish this?
One way is formula[[2]]<-substitute(transform(y),list(y=formula[[2]]))
Another way is to use update, e.g.
fo <- y ~ x update(fo, transform(.) ~ .)
transform(y) ~ x