Description Usage Arguments Details See Also Examples
This function maintains a data cache. When called, it will see if a "fresh"
data file is available. If not (i.e. the cache is "stale"), FUN
will
be called to retreive more up-to-date data. On systems supporting forking
(e.g. Linux and Mac OS X), the refreshing of data will occur in the background
and the most "fresh" data will be returned until that background process
completes.
1 2 | data.cache(FUN, frequency = daily, cache.dir = "cache",
cache.name = "Cache", envir = parent.frame(), wait = FALSE, ...)
|
FUN |
the function used to laod the data. |
frequency |
how frequently should the cache expire. |
cache.dir |
the directory containing the cached data files. |
cache.name |
name of the cache. |
envir |
the enviroment into which data will be loaded. |
wait |
should the function wait until stale data is refreshed. |
... |
other parameters passed to |
The FUN
parameter is required. This function should return a named
list
of objects. These objects will be assigned to the
given environment (the calling environment by default).
There are a number of frequencies available to determine when a cached file
becomes stale including: hourly
, daily
,
weekly
, monthly
, yearly
,
nMinutes
, nHours
, and nDays
.
It is possible to define custom frequencies. Each frequency function takes
one parameter, timestamp
, which has a class type of POSIXct
,
and returns a logical
value where TRUE
indicates the cache
created at timestamp
is stale.
See the Vignette (vignette('DataCache')
) or demo
(demo('WeatherCache')
) for more information.
daily, hourly, weekly, monthly, yearly, nMinutes, nHours, nDays
1 2 3 4 5 6 7 8 9 10 11 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.