Re: [Rd] caching frequently used values

2006-12-16 Thread Gabor Grothendieck
See: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/83547.html On 12/13/06, Tamas K Papp <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to find an elegant way to compute and store some > frequently used matrices "on demand". The Matrix package already uses > something like this for storing de

Re: [Rd] caching frequently used values

2006-12-13 Thread Henrik Bengtsson
I use the R.oo Object class for what has been suggested previously. The Object class can be thought of as utility wrapper class for environments (actually environments gained much of its behavior some time ago when "$" etc was being mapped to get() calls). For caching to file, take a look at the R

Re: [Rd] caching frequently used values

2006-12-13 Thread Seth Falcon
Tamas K Papp <[EMAIL PROTECTED]> writes: > On Wed, Dec 13, 2006 at 03:05:46PM -0800, Robert Gentleman wrote: > >> e1 = new.env(hash=TRUE) >> >> e1[["1"]] = whateveryouwant >> >> ie. just transform to characters, but I don't see why you want to do >> that - surely there are more informative name

Re: [Rd] caching frequently used values

2006-12-13 Thread Robert Gentleman
e1 = new.env(hash=TRUE) e1[["1"]] = whateveryouwant ie. just transform to characters, but I don't see why you want to do that - surely there are more informative names to be used - Tamas K Papp wrote: > Hi Robert, > > Thanks for your answer. I would create and environment with > new.env(),

Re: [Rd] caching frequently used values

2006-12-13 Thread Tamas K Papp
On Wed, Dec 13, 2006 at 03:05:46PM -0800, Robert Gentleman wrote: > e1 = new.env(hash=TRUE) > > e1[["1"]] = whateveryouwant > > ie. just transform to characters, but I don't see why you want to do > that - surely there are more informative names to be used - Because they are derivatives, and b

Re: [Rd] caching frequently used values

2006-12-13 Thread Tamas K Papp
Hi Robert, Thanks for your answer. I would create and environment with new.env(), but how can I assign and retrieve values based on a numerical index (the derivative)? The example of the help page of assign explicitly shows that assign("a[1]") does not work for this purpose. Thanks, Tamas On

Re: [Rd] caching frequently used values

2006-12-13 Thread Robert Gentleman
the idea you are considering is also, at times, referred to as memoizing. I would not use a list, but rather an environment, and basically you implement something that first looks to see if there is a value, and if not, compute and store. It can speed things up a lot in some examples (and slow

[Rd] caching frequently used values

2006-12-13 Thread Tamas K Papp
Hi, I am trying to find an elegant way to compute and store some frequently used matrices "on demand". The Matrix package already uses something like this for storing decompositions, but I don't know how to do it. The actual context is the following: A list has information about a basis of a B-