"Roger D. Peng" <[EMAIL PROTECTED]> writes:

> I've encountered a (I think) related problem when using promises to load 
> relatively large datasets.  For example something like
>
> delayedAssign("x", getBigDataset())
>
> runs into the same problem if you hit Ctrl-C while 'x' is being evaluated for 
> the first time.  Afterwards, there's no way to retrieve the dataset 
> associated 
> with 'x'.
>
> Active bindings work in this case, but the problem is that I usually only 
> want 
> to load a large dataset once.

You can do that with active bindings.  Have the function look in an
environment for the data.  If found, return it.  If not, load it into
the env and then return it.

We are using this approach in the BSGenome package in BioC (look there
for an example if you want) and it provides behavior very similar to
lazy data, but more manageable in a number of ways.

+ seth

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to