[R] how to trigger variable creation?

Thomas Liebig thomas.liebig at iais.fraunhofer.de
Fri Jun 12 15:29:43 CEST 2009


well,
for sure, one option is to trace the garbage collector gc() by a 
function that enumerates the list of known objects and compares this 
with its successor. But that's not reliable, as i can't really control 
when to call the garbage collector. i also don't like to enumerate 
objects and to compare these lists at each time step.

what else could be done?

cheers,
Thomas

Thomas Liebig schrieb:
> Hello R users,
> 
> i'm wondering how to trigger variable creation.
> Whenever a variable is created i want my own function myFun(...) to be 
> started.
> 
> if (exists("x")) {rm(x)} # after removal of x
>                          # any of these calls
> x<-10                    # should call myFun
> x=10                     # should call myFun
> assign(x,10)             # should call myFun
> etc.
>                          # afterwards, each of the calls
> x<-15                    # should not call myFun
> x=15                     # should not call myFun
> assign(x,15)             # should not call myFun
> etc.
> 
> Has anyone an idea? Unfortunately, this feature is also missing in the 
> library trackObjs.
> 
> regards,
> Thomas
> 

-- 
Thomas Liebig
Fraunhofer-Institut für Intelligente Analyse- und
Informationssysteme (IAIS)

Schloss Birlinghoven, D-53754 Sankt Augustin, Germany
Email:  thomas.liebig at iais.fraunhofer.de
Phone:  +49 2241 142050
Fax:    +49 2241 142072




More information about the R-help mailing list