_
From: [EMAIL PROTECTED] on behalf of Renaud Lancelot
Sent: Sat 7/8/2006 6:25 PM
To: Cleber N.Borges
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] String mathematical function to R-function [Broadcast]
> fun_String <- "-100*x1 + 0*x2 + 100*x3"
>
> fun <- function(
> fun_String <- "-100*x1 + 0*x2 + 100*x3"
>
> fun <- function(x1, x2, x3){
+ eval(parse(text = fun_String))
+ }
>
> fun(4:0, -2:2, 0:4)
[1] -400 -2000 200 400
Best,
Renaud
2006/7/8, Cleber N.Borges <[EMAIL PROTECTED]>:
>
>
> hello
>
> I make a subroutine that give-me a (mathematical)
>
hello
I make a subroutine that give-me a (mathematical)
function in string format.
I would like transform this string into function ( R
function ).
thanks for any tips.
cleber
#e.g.
fun_String = "-100*x1 + 0*x2 + 100*x3"
fun <- function(x1,x2,x3){
return(
evaluation( fun_String