[R] help in substitute function
Ronaldo Reis Junior
chrysopa at gmail.com
Fri Oct 5 15:20:33 CEST 2007
Hi,
I try to use a substitute function to generalise a equation.
I have this:
expression(1+2*pred+3*lat)
I need to define the equation in function of x1 and x2 variables. Also I try
to define who is x1 and x2. I try this:
X1 <- "pred"
X2 <- "lat"
Now I need substitute pred and lat in equation by x1 and x2 defined on X1 and
X2 above, I try this way:
>
substitute(expression(1+2*pred+3*lat),list(as.name(X1)=as.name(x1),as.name(X2)=as.name(x2))
Error: unexpected '='
in "substitute(expression(1+2*pred+3*lat),list(as.name(X1)="
My expected result is:
expression(1 + 2 * x1 + 3 * x2)
Any help?
Thanks
Ronaldo
--
> Prof. Ronaldo Reis Júnior
| .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Biologia Computacional
| : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
| `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
| `- Fone: (38) 3229-8187 | ronaldo.reis em unimontes.br | chrysopa em gmail.com
| http://www.ppgcb.unimontes.br/ | ICQ#: 5692561 | LinuxUser#: 205366
More information about the R-help
mailing list