On cooking shows, recipes requiring lengthy baking or stewing are prepared beforehand. The bake and stew functions perform analogously, performing an R computation and storing the result in a named file. If the function is called again and the file is present, the computation is not executed; rather, the results are loaded from the file in which they were previously stored. Moreover, via their optional seed and kind arguments, bake and stew can control the pseudorandom-number generator (RNG) for greater reproducibility. After the computation is finished, these functions restore the pre-existing RNG state to avoid side effects.

The freeze function doesn’t save results, but does set the RNG state to the specified value and restore it after the computation is complete.


NSF
NCEAS
NIH

This software has been made possible by support from the U.S. National Science Foundation (Grants #EF-0545276, #EF-0430120), by the “Inference for Mechanistic Models” Working Group supported by the National Center for Ecological Analysis and Synthesis (a Center funded by N.S.F. (Grant #DEB-0553768), the University of California, Santa Barbara, and the State of California), and by the RAPIDD program of the Science & Technology Directorate, Department of Homeland Security and the Fogarty International Center, U.S. National Institutes of Health.