# [R] help in substitute function

From: Ronaldo Reis Junior <chrysopa_at_gmail.com>
Date: Fri, 5 Oct 2007 10:20:33 -0300

Hi,

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_at_unimontes.br | chrysopa_at_gmail.com
| http://www.ppgcb.unimontes.br/ | ICQ#: 5692561 | LinuxUser#: 205366

______________________________________________
R-help_at_r-project.org 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.
```
Received on Fri 05 Oct 2007 - 13:26:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 25 Oct 2007 - 11:32:52 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.