redirect: redirect

View source: R/redirect.R

redirectR Documentation

redirect

Description

Redirect a given dataset type to a different source folder. The redirection is local, so it will be reset when the current function call returns. See example for more details.

Usage

redirect(type, target, linkOthers = TRUE, local = TRUE)

Arguments

type

Dataset name, e.g. "Tau" for readTau

target

Either path to the new source folder that should be used instead of the default, or NULL to remove the redirection, or a vector of paths to files which are then symlinked into a temporary folder that is then used as target folder; if the vector is named the names are used as relative paths in the temporary folder, e.g. target = c('a/b/c.txt' = "~/d/e/f.txt") would create a temporary folder with subfolders a/b and there symlink c.txt to ~/d/e/f.txt.

linkOthers

If target is a list of files, whether to symlink all other files in the original source folder to the temporary folder.

local

The scope of the redirection, passed on to setConfig. Defaults to the current function. Set to an environment for more control or to FALSE for a permanent/global redirection.

Value

Invisibly, the source folder that is now used for the given type

Author(s)

Pascal Sauer

Examples

## Not run: 
f <- function() {
  redirect("Tau", target = "~/TauExperiment")
  # the following call will change directory
  # into ~/TauExperiment instead of <getConfig("sourcefolder")>/Tau
  readSource("Tau")
}
f()
# Tau is only redirected in the local environment of f,
# so it will use the usual source folder here
readSource("Tau")

## End(Not run)

pik-piam/madrat documentation built on May 19, 2024, 11:43 p.m.