read_or_cache | R Documentation |
This function wraps read_or_process()
, specifying an app's cache directory
as the target directory.
read_or_cache( source_path, appname, filename = construct_processed_filename(source_path), process_f = readRDS, process_args = NULL, read_f = readRDS, read_args = NULL, write_f = saveRDS, write_args = NULL, force_process = FALSE )
source_path |
Character scalar; the path to the raw file. Paths starting
with |
appname |
Character; the name of the application that will "own" the cache, such as the name of a package. |
filename |
Character; an optional filename for the cached version of the
file. By default, a filename is constructed using
|
process_f |
A function or one-sided formula to use to process the source
file. |
process_args |
An optional list of additional arguments to |
read_f |
A function or one-sided formula to use to read the processed
file. |
read_args |
An optional list of additional arguments to |
write_f |
A function or one-sided formula to use to save the processed
file. The processed object will be passed as the first argument to this
function, and |
write_args |
An optional list of additional arguments to |
force_process |
A logical scalar indicating whether we should process the source file even if the target already exists. This can be particularly useful if you wish to redownload a file. |
The processed object.
if (interactive()) { austin_smoke_free <- read_or_cache( "https://query.data.world/s/owqxojjiphaypjmlxldsp566lck7co", appname = "dlr", process_f = read.csv ) head(austin_smoke_free) } if (interactive()) { # Calling the function a second time gives the result instantly. austin_smoke_free <- read_or_cache( "https://query.data.world/s/owqxojjiphaypjmlxldsp566lck7co", appname = "dlr", process_f = read.csv ) head(austin_smoke_free) } if (interactive()) { # Remove the generated file. unlink( construct_cached_file_path( "https://query.data.world/s/owqxojjiphaypjmlxldsp566lck7co" ) ) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.