H. Dieter Wilhelm
2014-Oct-07  06:45 UTC
[R] Evaluation of global variables in function definitions
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, Germany
Duncan Murdoch
2014-Oct-07  13:54 UTC
[R] Evaluation of global variables in function definitions
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 > DieterSee the "open.account" example in section 10.7, "Scope", of the Introduction to R manual. Duncan Murdoch