[R] environment or other technique to isolate some private working information

Prof. John C Nash nashjc at uottawa.ca
Fri Oct 30 15:05:57 CET 2009


In order to instrument functions for optimization or DE solving etc., I
want to set up a private ensemble of working data somewhere in my
workspace that won't collide with the problem-data. I can do this
already with named objects within .GlobalEnv, but I'd like to have
functions like

fnmon.setup<-function( etc. ) {

...
 # create an environment
    monenv<-new.env(baseenv())

# then create some names in the monenv for a file of data to be written,
#  some counters, timers etc.

}

and within my function call a function
  fnmon.next<- ...

that gets the appropriate infomation from the special area writes lines
to the monitoring file

and finally

  fnmon.stop<-....

to close things out.

I've got it working with objects in .GlobalEnv as indicated, but
attempts to do it as above cause failure to find the environment in the
fnmon.next.

Likely I'm misreading the documentation on 'environment' somehow (it may
be clear to folks who are deep into Lisp/Scheme, but not mere mortals).
Or perhaps there is a better way to isolate the private collection of
objects that will do the monitoring.

I can provide the files to anyone wanting a tryout, but they are a bit
long, and I suspect there is an "easy" approach that is eluding me.

JN




More information about the R-help mailing list