Ronaldo Reis Junior asked:
>
> I try to use a substitute function to generalise a equation.
>
> I have this:
>
> expression(1+2*pred+3*lat)
>
> (...) My expected result is:
>
> expression(1 + 2 * x1 + 3 * x2)
>
Check message by Thomas Lumley on 2007-03-27 (command...
RSiteSearch("Replacement in an expression - can't use parse()")
... will get it among others)
Quoting and adapting:
e <- expression(1+2*pred+3*lat)
do.call("substitute", list(e[[1]], list(pred=quote(x1),lat=quote(x2))))
# 1 + 2 * x1 + 3 * x2
(parece mágica, não é?)
Alberto Monteiro
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.