Create the path to a temporary file inside drake's cache.
Usage
drake_tempfile(path = NULL, cache = drake::drake_cache(path = path))
Arguments
- path
Path to a
drake
cache (usually a hidden.drake/
folder) orNULL
.- cache
drake cache. See
new_cache()
. If supplied,path
is ignored.
Details
This function is just like the tempfile()
function in base R
except that the path points to a special location inside drake
's cache.
This ensures that if the file needs to be copied to
persistent storage in the cache, drake
does not need to copy across
physical storage media. Example: the "diskframe"
format. See the
"Formats" and "Columns" sections of the drake_plan()
help file.
Unless you supply the cache or the path to the cache
(see drake_cache()
) drake
will assume the cache folder is named
.drake/
and it is located either in your working directory or an
ancestor of your working directory.
Examples
cache <- new_cache(tempfile())
# No need to supply a cache if a .drake/ folder exists.
drake_tempfile(cache = cache)
#> [1] "/tmp/RtmpcDvjO6/file13c772eed1ab/drake/tmp/file13c71c8d1908"
drake_plan(
x = target(
as.disk.frame(large_data, outdir = drake_tempfile()),
format = "diskframe"
)
)
#> # A tibble: 1 × 3
#> target command format
#> <chr> <expr_lst> <chr>
#> 1 x as.disk.frame(large_data, outdir = drake_tempfile()) diskframe