redirectSource: redirectSource

View source: R/redirectSource.R

redirectSourceR Documentation

redirectSource

Description

redirectSource will call a source specific redirect function if it exists (called e.g. redirectTau), in which case the arguments are passed on to that function. If such a function is not available redirect is called.

Usage

redirectSource(type, target, ..., linkOthers = TRUE, local = TRUE)

Arguments

type

Dataset name, e.g. "Tau" to set the source folder that readTau will use

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.

...

Additional arguments, passed on to the specific redirect function.

linkOthers

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

local

If TRUE the redirection is only temporary and will be reset when the function which calls redirect is finished. Set to FALSE for a permanent/global redirection or to an environment for more control.

Value

The result of the specific redirect function or redirect.

Author(s)

Pascal Sauer

Examples

## Not run: 
f <- function() {
  redirectSource("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 July 4, 2025, 4:56 a.m.