Re: [R] Evaluation of global variables in function definitions

2014-10-08 Thread William Dunlap
fFactory <- function(args) { a <- complicated_a_computation(args) b <- complicated_b_computation(args) function(x) a*x + b*exp(x) } f1 <- fFactory(args1) f2 <- fFactory(args2) f1(x) f2(x) # will get different result than f1(x) f1 and f2 will look the same but produce different results

Re: [R] Evaluation of global variables in function definitions

2014-10-08 Thread Duncan Murdoch
On 08/10/2014 5:53 AM, H. Dieter Wilhelm wrote: Duncan Murdoch writes: > On 07/10/2014 2:45 AM, H. Dieter Wilhelm wrote: >> Hello (), >> >> I'd like to do the following >> >> a <- 3 >> f1 <- function (x){ >> a*x^2 >> } >> >> a <- 5 >> f2 <- function (x){ >> a*x^2 >> } >> >> plotting f1, f2,

Re: [R] Evaluation of global variables in function definitions

2014-10-08 Thread H. Dieter Wilhelm
Duncan Murdoch writes: > On 07/10/2014 2:45 AM, H. Dieter Wilhelm wrote: >> Hello (), >> >> I'd like to do the following >> >> a <- 3 >> f1 <- function (x){ >> a*x^2 >> } >> >> a <- 5 >> f2 <- function (x){ >> a*x^2 >> } >> >> plotting f1, f2, ... >> >> but f1 and f2 are the same, how can I e

Re: [R] Evaluation of global variables in function definitions

2014-10-07 Thread Duncan Murdoch
On 07/10/2014 2:45 AM, H. Dieter Wilhelm wrote: Hello (), I'd like to do the following a <- 3 f1 <- function (x){ a*x^2 } a <- 5 f2 <- function (x){ a*x^2 } plotting f1, f2, ... but f1 and f2 are the same, how can I evaluated the variables in the function definition? Thank you Di

[R] Evaluation of global variables in function definitions

2014-10-07 Thread H. Dieter Wilhelm
Hello (), I'd like to do the following a <- 3 f1 <- function (x){ a*x^2 } a <- 5 f2 <- function (x){ a*x^2 } plotting f1, f2, ... but f1 and f2 are the same, how can I evaluated the variables in the function definition? Thank you Dieter -- Best wishes H. Dieter Wilhelm Darmstadt, Ger