[R] problems with function-formating, please help

From: Joerg Burmester <joerg-burmester_at_gmx.net>
Date: Sat 06 Aug 2005 - 18:43:53 EST


please help me.

since 2 days i have tried desperately to find desperately a solution for the following problem:

i have an array of 3 different vectors like:

> clustertransformationstabelle[,15:17]

          x1            x2                x3
1  0.6270023 0.2464946 0.5074781
2  0.5629291 0.1783861 0.4398626

3 0.6773455 0.3107641 0.5637289
4 0.0000000 0.0000000 0.0000000

i want to calculate a corresponding result-vector with a formula resp function eg:

> result <- - 1.60638946783994e-05 + 384.649339378693 * x1 - 168.920548209815 * x2 - 693.51261768584 * x3 + 479.305764753298 * x1 * x3

after formating the result would look like
> dim(result) <- c(4,1)
> result

               [,1]

 [1,]  1.057852e-01
 [2,]  2.854227e-02
 [3,]  1.107150e-01
 [4,] -1.606389e-05

fine....
but due to mass routines, i have to create the result-function automatically, unfortunately it can only be generated via a paste-command as a character-string in quotes like:

functionterm <- "- 1.60638946783994e-05 + 384.649339378693 * x1 - 168.920548209815 * x2 - 693.51261768584 * x3 + 479.305764753298 * x1 * x3"

how on earth can i use that automatically generated functionterm (see line above), unfortunately inclusive their quotes, in order to get a correct fomated function?

if i try to convert it into a function like:
> result <- as.function(alist(x1=,x2=,x3=, functionterm))

and give some example input-data eg.:
> result(0.6270023, 0.2464946, 0.5074781)

i always get that stupid functionterm in quotes returned [1] "- 1.60638946783994e-05 + 384.649339378693 * x1 - 168.920548209815 * x2 - 693.51261768584 * x3 + 479.305764753298 * x1 * x3"

instead of the correct values (like 1.057852e-01, see result-array[1,1] some lines above) please help me, i am blocked since 2 days already by that stupid problem

joerg burmester

Phone: +49-(0)4131-40898-5
Mobile Phone: +49-(0)177-4812371
Fax: +49-(0)4131-40898-7
Email: joerg-burmester@gmx.net

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Aug 06 18:50:43 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:44 EST