[R] Evaluation of global variables in function definitions

Duncan Murdoch murdoch.duncan at gmail.com
Tue Oct 7 15:54:49 CEST 2014


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
>        Dieter
See the "open.account" example in section 10.7, "Scope", of the 
Introduction to R manual.

Duncan Murdoch



More information about the R-help mailing list