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
On 10/5/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> Given this:
>
> x1 <- "pred"
> x2 <- "lat"
> e <- expression(1+2*pred+3*lat)
>
> Try this:
>
> L <- list(as.name("x1"), as.name("x2"))
> names(L) <- c(x1, x2)
> do.call(substitute, list(e, L)) # e & L are evaluated first
>
> or perhaps:
>
Given this:
x1 <- "pred"
x2 <- "lat"
e <- expression(1+2*pred+3*lat)
Try this:
L <- list(as.name("x1"), as.name("x2"))
names(L) <- c(x1, x2)
do.call(substitute, list(e, L)) # e & L are evaluated first
or perhaps:
f <- e
f <- sub("pred", "x1", f) # also converts to character
f <- sub("lat", "x2
Hi,
try this(Not tested):
substitute(expression(1+2*pred+3*lat),list(pred=as.name(x1),lat=as.name(x2)))
On 05/10/2007, Ronaldo Reis Junior <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I try to use a substitute function to generalise a equation.
>
> I have this:
>
> expression(1+2*pred+3*lat)
>
> I
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 equatio
5 matches
Mail list logo