Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Gabor Grothendieck
On 4/4/06, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > On 4/4/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > > On 4/4/06, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > > > On 4/4/06, Thomas Lumley <[EMAIL PROTECTED]> wrote: > > > > On Tue, 4 Apr 2006, Henrik Bengtsson wrote: > > > > > > > >

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Henrik Bengtsson
On 4/4/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > On 4/4/06, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > > On 4/4/06, Thomas Lumley <[EMAIL PROTECTED]> wrote: > > > On Tue, 4 Apr 2006, Henrik Bengtsson wrote: > > > > > > > Hi, > > > > > > > > this relates to the question "How to set a fo

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Henrik Bengtsson
On 4/4/06, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > On Tue, 4 Apr 2006, Roger D. Peng wrote: > > > In R 2.3.0-to-be, I think you can do > > > > foo <- function(huge) { > > scale <- mean(huge) > > g <- function(x) { scale * x } > > environment(g) <- emptyenv() > > g > >

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Martin Maechler
> "Roger" == Roger D Peng <[EMAIL PROTECTED]> > on Tue, 04 Apr 2006 10:38:29 -0400 writes: Roger> In R 2.3.0-to-be, I think you can do Roger> foo <- function(huge) { Roger> scale <- mean(huge) Roger> g <- function(x) { scale * x } Roger> environment(g) <- emptyenv(

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Gabor Grothendieck
On 4/4/06, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > On 4/4/06, Thomas Lumley <[EMAIL PROTECTED]> wrote: > > On Tue, 4 Apr 2006, Henrik Bengtsson wrote: > > > > > Hi, > > > > > > this relates to the question "How to set a former environment?" asked > > > yesterday. What is the best way to to r

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Henrik Bengtsson
On 4/4/06, Thomas Lumley <[EMAIL PROTECTED]> wrote: > On Tue, 4 Apr 2006, Henrik Bengtsson wrote: > > > Hi, > > > > this relates to the question "How to set a former environment?" asked > > yesterday. What is the best way to to return a function with a > > minimal environment from a function? Here

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Prof Brian Ripley
On Tue, 4 Apr 2006, Roger D. Peng wrote: > In R 2.3.0-to-be, I think you can do > > foo <- function(huge) { > scale <- mean(huge) > g <- function(x) { scale * x } > environment(g) <- emptyenv() > g > } You can, but you really don't want to and you will get the same error.

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Roger D. Peng
In R 2.3.0-to-be, I think you can do foo <- function(huge) { scale <- mean(huge) g <- function(x) { scale * x } environment(g) <- emptyenv() g } -roger Henrik Bengtsson wrote: > Hi, > > this relates to the question "How to set a former environment?" asked > yeste

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Thomas Lumley
On Tue, 4 Apr 2006, Henrik Bengtsson wrote: > Hi, > > this relates to the question "How to set a former environment?" asked > yesterday. What is the best way to to return a function with a > minimal environment from a function? Here is a dummy example: > > foo <- function(huge) { > scale <- mean