switchTo: switchTo

switchToR Documentation

switchTo

Description

Switch to a different computing environment (set of installed R packages and library location paths for new pkg installs)

Usage

switchTo(
  name,
  seed = NULL,
  reverting = FALSE,
  ignoreRVersion = FALSE,
  exclude.site = TRUE,
  ...
)

## S4 method for signature 'character,character'
switchTo(
  name,
  seed = NULL,
  reverting = FALSE,
  ignoreRVersion = FALSE,
  exclude.site = TRUE,
  ...
)

## S4 method for signature 'character,SwitchrCtx'
switchTo(
  name,
  seed = NULL,
  reverting = FALSE,
  ignoreRVersion = FALSE,
  exclude.site = TRUE,
  ...
)

## S4 method for signature 'character,missing'
switchTo(
  name,
  seed = NULL,
  reverting = FALSE,
  ignoreRVersion = FALSE,
  exclude.site = TRUE,
  ...
)

## S4 method for signature 'SwitchrCtx,ANY'
switchTo(
  name,
  seed = NULL,
  reverting = FALSE,
  ignoreRVersion = FALSE,
  exclude.site = TRUE,
  ...
)

## S4 method for signature 'character,RepoSubset'
switchTo(
  name,
  seed = NULL,
  reverting = FALSE,
  ignoreRVersion = FALSE,
  exclude.site = TRUE,
  ...
)

## S4 method for signature 'character,PkgManifest'
switchTo(
  name,
  seed = NULL,
  reverting = FALSE,
  ignoreRVersion = FALSE,
  exclude.site = TRUE,
  ...
)

## S4 method for signature 'character,SessionManifest'
switchTo(
  name,
  seed = NULL,
  reverting = FALSE,
  ignoreRVersion = FALSE,
  exclude.site = TRUE,
  ...
)

Arguments

name

The name associated (or to associate) with the computing environment.

seed

The seed, indicating packages to install into a newly created package library No effect if the library already exists

reverting

Indicates whether we are reverting to the environment in use before the current one. Typically not set directly by the user.

ignoreRVersion

Should the R version in use be ignored when checking for existing computing environmeSnts. This is experimental.

exclude.site

Should the Site library be excluded when creating and switching to the specified library. Defaults to TRUE

...

Passed directly to makeLibraryCtx if an existing computing environment is not found.

Details

If switchr does not now about the specified computing environment, a new one will be created via installCompEnv. This includes creating a directory under the switchr base directory and installing packages into it. See installCompEnv for more details.

This function has the side effect of unloading all loaded packages (other than base packages, GRAN or GRANBAse, switchr itself, and switchr's dependencies) and the associated DLLs. It also changes the library location R will use to search for packages, e.g. when you call library.

This means you will have to reinstall packages after switching, which is important and intended (e.g. when switching to using Bioc devel from Bioc release).

Value

Invisibly returns the SwitchrCtx object representing the new computing environment

Note

By default, this process involves a call to flushSession which will attempt to unload all loaded packages. While some support of configuring what is unloaded is provided via switchrDontUnload, it is recommended that you turn this feature entirely off via switchrNoUnload(TRUE) when using switchr within dyanmic documents (.Rnw/.Rmd files, etc), particularly when using the knitr package.

References

Becker G, Barr C, Gentleman R, Lawrence M; Enhancing Reproducibility and Collaboration via Management of R Package Cohorts. Journal of Statistical Software, 81(1). 2017. doi: 10.18637/jss.v082.i01

See Also

makeLibraryCtx

Examples

## Not run: 
switchTo("mynewlibrary")
switchBack()

fdman = GithubManifest("gmbecker/fastdigest")
switchTo("fastdigestlib", seed = fdman)

## End(Not run)

gmbecker/switchr documentation built on Feb. 24, 2023, 12:59 p.m.