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

Paul Johnson pauljohn32 at gmail.com
Tue May 29 19:41:18 CEST 2012


>>
>
> Try substitute:
>
>> do.call("substitute", list(newFmla, setNames(list(as.name("x1c")), "x1")))
> y ~ log(x1c) + x2 * x3
>
Damn. That's pretty. I'd say "setNames" a magic bullet too.

Thanks very much.

The approach suggested by Michael and Bert has the little shortcoming
that grepping for "x1" also picks up similarly named variables like
"x1new" and "x1old".  I've not yet found a similar downside with
Gabor's method.

pj
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com



-- 
Paul E. Johnson
Professor, Political Science    Assoc. Director
1541 Lilac Lane, Room 504     Center for Research Methods
University of Kansas               University of Kansas
http://pj.freefaculty.org            http://quant.ku.edu



More information about the R-help mailing list