Re: [R] environment and scoping

2008-10-04 Thread Gabor Grothendieck
Please provide complete examples that include test drivers. Here is main.fun reworked to eliminate the error in the arg list and also changing the environment of aux.fun: main.fun <- function(aux.fun, dat) { x <- 1 environment(aux.fun) <- environment() aux.fun() } aux.fun.one <- function

Re: [R] environment and scoping

2008-10-04 Thread Charles C. Berry
Rene, What you have below does not make much sense. You have not provided a definition for fun.dat() nor have you given an example with which to run any of your functions. The issue you raise about passing 'dat variable as a parameter as it can get pretty large' is not an issue. Observ

Re: [R] environment and scoping

2008-10-04 Thread hadley wickham
What's wrong with explicitly passing the variables as arguments to the function? aux.fun.one <- function(dat, x){ median(dat) - x } Hadley On Sat, Oct 4, 2008 at 11:50 AM, René Holst <[EMAIL PROTECTED]> wrote: > I haven't quite figured out how I can change the environment of a function. > I ha

[R] environment and scoping

2008-10-04 Thread René Holst
I haven't quite figured out how I can change the environment of a function. I have a main function and want to use different auxillary functions, which I supply as parameter (or names). What I want to do is something like this: main.fun=function(aux.fun,dat){ x <- 1 fun.dat() } aux.fun.one