2009/7/2 Peter Dalgaard <p.dalga...@biostat.ku.dk>: > Mark Wardle wrote: >> [...] >> Otherwise, it sounds like a recipe for obfuscation! What are you >> trying to do really? > > Not really obfuscation, there are legitimate reasons to want this sort of > behaviour. See demo(scoping) for a related example > [...]
I would have implemented this using either a OO approach or (if there was not going to be future code re-use) by defining a hidden variable with a lazy initialisation helper function that returns a cached value of the data or acquires data for the first time. Not as elegant as the solution given by Dr. Dalgaard. -- Dr. Mark Wardle Specialist registrar, Neurology Cardiff, UK ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.