View source: R/exportedMethods.R
| remapFilenames | R Documentation |
Update file path metadata for file-backed objects (e.g., SpatRasters).
Useful when moving saved objects between projects or machines.
remapFilenames(obj, tags, cachePath = getOption("reproducible.cachePath"), ...)
obj |
(optional) object whose file path metadata will be remapped |
tags |
cache tags |
cachePath |
character string specifying the path to the cache directory or |
... |
Additional path arguments, passed to |
# A file-backed object cached on one machine records where its files lived.
# remapFilenames() translates those to where they belong on THIS machine,
# using the anchors (e.g. inputPath) supplied in `paths`.
inputDir <- file.path(tempdir(), "remapExample")
dir.create(inputDir, showWarnings = FALSE)
tags <- c(
"origFilename:dem.tif",
"origRelName:dem.tif",
"relToWhere:inputPath", # the anchor the file was stored relative to
"filesToLoad:/some/other/machine/inputs/dem.tif"
)
newFiles <- remapFilenames(
tags = tags, cachePath = NULL,
paths = list(inputPath = inputDir)
)
newFiles$newName # now under THIS machine's inputPath
unlink(inputDir, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.