Learn R Programming

⚠️There's a newer version (2.0.1) of this package.Take me there.

memoise

If a function is called multiple times with the same input, you can often speed things up by keeping a cache of known answers that it can retrieve. This is called memoisation http://en.wikipedia.org/wiki/Memoization. The memoise package provides a simple syntax

mf <- memoise(f)

to create mf(), a memoised wrapper around f(). You can clear mf's cache with

forget(mf)

, and you can test whether a function is memoised with

is.memoised(mf) # TRUE
is.memoised(f)  # FALSE

.

Copy Link

Version

Install

install.packages('memoise')

Monthly Downloads

739,211

Version

1.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Jim Hester

Last Published

January 29th, 2016

Functions in memoise (1.0.0)

timeout

Return a new number after a given number of seconds
has_cache

Test whether a memoised function has been cached for particular arguments.
forget

Forget past results. Resets the cache of a memoised function.
memoise

Memoise a function.
is.memoised

Test whether a function is a memoised copy. Memoised copies of functions carry an attribute memoised = TRUE, which is.memoised() tests for.