Installing, Managing, and Switching Between Distinct Sets of Installed Packages
Overview
Provides an abstraction for managing, installing, and switching between sets of installed R packages. This allows users to maintain multiple package libraries simultaneously, e.g. to maintain strict, package-version-specific reproducibility of many analyses, or work within a development/production release paradigm. Introduces a generalized package installation process which supports multiple repository and non-repository sources and tracks package provenance.
Install
Health
ERRORtestsr-devel-windows-x86_64, r-release-macos-arm64, r-release-macos-x86_64, r-release-windows-x86_64
r-devel-windows-x86_64, r-release-windows-x86_64
Running 'winpath.R' [7s]
Running the tests in 'tests/winpath.R' failed.
Complete output:
> library(switchr)
> ## if(getOption("repos")["CRAN"] == "@CRAN@")
> ## chooseCRANmirror(ind=1L)
> graceful_inet(TRUE)
$on
[1] TRUE
$silent
[1] FALSE
> checkUrlRoundtrip = function(pth) {
+ pth = switchr:::normalizePath2(pth)
+ furl = switchr:::makeFileURL(pth)
+ pth2 = switchr:::fileFromFileURL(furl)
+ if(pth != pth2)
+ stop("Round trip result (", pth2, ") does not match original (", pth, ") when creating file URLs")
+ }
>
> ## regression test to ensure that the roundtrip
> ## between path and file url is working properly
> checkUrlRoundtrip(getwd())
> checkUrlRoundtrip(tempdir())
> if(switchr:::isWindows())
+ checkUrlRoundtrip("\\\\localhost\\c$")
>
> ## regreossion test to ensure that package dependencies
> ## are added to the dontunload list when a package
> ## is specified
> bef = switchrDontUnload()
> af = switchrDontUnload("knitr")
> stopifnot(all(tools::package_dependencies("knitr", recursive = TRUE)[[1]] %in% af))
>
>
> ## regression test for unnecessary (and expensive)
> ## lazy repo construction when install_packages
> ## is passed urls for existing repos (the default
> ## behavior).
> tmplib = tempdir()
> trace(lazyRepo, stop)
Tracing function "lazyRepo" in environment <namespace:switchr>
Warning: Tracing only in the namespace; to untrace you will need:
untrace("lazyRepo", where = getNamespace("switchr"))
[1] "lazyRepo"
attr(,"package")
[1] "switchr"
> install_packages("switchr", repos = defaultRepos(), lib = tmplib)
Error in rbind(avail1, avail2[new, ]) :
number of columns of matrices must match (see arg 2)
Calls: install_packages ... install_packages -> install_packages -> .install_packages -> rbind
Execution haltedr-release-macos-arm64
Running ‘winpath.R’ [1s/4s]
Running the tests in ‘tests/winpath.R’ failed.
Complete output:
> library(switchr)
> ## if(getOption("repos")["CRAN"] == "@CRAN@")
> ## chooseCRANmirror(ind=1L)
> graceful_inet(TRUE)
$on
[1] TRUE
$silent
[1] FALSE
> checkUrlRoundtrip = function(pth) {
+ pth = switchr:::normalizePath2(pth)
+ furl = switchr:::makeFileURL(pth)
+ pth2 = switchr:::fileFromFileURL(furl)
+ if(pth != pth2)
+ stop("Round trip result (", pth2, ") does not match original (", pth, ") when creating file URLs")
+ }
>
> ## regression test to ensure that the roundtrip
> ## between path and file url is working properly
> checkUrlRoundtrip(getwd())
> checkUrlRoundtrip(tempdir())
> if(switchr:::isWindows())
+ checkUrlRoundtrip("\\\\localhost\\c$")
>
> ## regreossion test to ensure that package dependencies
> ## are added to the dontunload list when a package
> ## is specified
> bef = switchrDontUnload()
> af = switchrDontUnload("knitr")
> stopifnot(all(tools::package_dependencies("knitr", recursive = TRUE)[[1]] %in% af))
>
>
> ## regression test for unnecessary (and expensive)
> ## lazy repo construction when install_packages
> ## is passed urls for existing repos (the default
> ## behavior).
> tmplib = tempdir()
> trace(lazyRepo, stop)
Tracing function "lazyRepo" in environment <namespace:switchr>
Warning: Tracing only in the namespace; to untrace you will need:
untrace("lazyRepo", where = getNamespace("switchr"))
[1] "lazyRepo"
attr(,"package")
[1] "switchr"
> install_packages("switchr", repos = defaultRepos(), lib = tmplib)
Error in rbind(avail1, avail2[new, ]) :
number of columns of matrices must match (see arg 2)
Calls: install_packages ... install_packages -> install_packages -> .install_packages -> rbind
Execution haltedr-release-macos-x86_64
Running ‘winpath.R’ [4s/9s]
Running the tests in ‘tests/winpath.R’ failed.
Complete output:
> library(switchr)
> ## if(getOption("repos")["CRAN"] == "@CRAN@")
> ## chooseCRANmirror(ind=1L)
> graceful_inet(TRUE)
$on
[1] TRUE
$silent
[1] FALSE
> checkUrlRoundtrip = function(pth) {
+ pth = switchr:::normalizePath2(pth)
+ furl = switchr:::makeFileURL(pth)
+ pth2 = switchr:::fileFromFileURL(furl)
+ if(pth != pth2)
+ stop("Round trip result (", pth2, ") does not match original (", pth, ") when creating file URLs")
+ }
>
> ## regression test to ensure that the roundtrip
> ## between path and file url is working properly
> checkUrlRoundtrip(getwd())
> checkUrlRoundtrip(tempdir())
> if(switchr:::isWindows())
+ checkUrlRoundtrip("\\\\localhost\\c$")
>
> ## regreossion test to ensure that package dependencies
> ## are added to the dontunload list when a package
> ## is specified
> bef = switchrDontUnload()
> af = switchrDontUnload("knitr")
> stopifnot(all(tools::package_dependencies("knitr", recursive = TRUE)[[1]] %in% af))
>
>
> ## regression test for unnecessary (and expensive)
> ## lazy repo construction when install_packages
> ## is passed urls for existing repos (the default
> ## behavior).
> tmplib = tempdir()
> trace(lazyRepo, stop)
Tracing function "lazyRepo" in environment <namespace:switchr>
Warning: Tracing only in the namespace; to untrace you will need:
untrace("lazyRepo", where = getNamespace("switchr"))
[1] "lazyRepo"
attr(,"package")
[1] "switchr"
> install_packages("switchr", repos = defaultRepos(), lib = tmplib)
Error in rbind(avail1, avail2[new, ]) :
number of columns of matrices must match (see arg 2)
Calls: install_packages ... install_packages -> install_packages -> .install_packages -> rbind
Execution haltedNOTECRAN incoming feasibilityr-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc
Maintainer: ‘Gabriel Becker <gabembecker@gmail.com>’
No Authors@R field in DESCRIPTION.
Please add one, modifying
Authors@R: person(given = "Gabriel",
family = "Becker",
role = c("aut", "cre"),
email = "gabembecker@gmail.com")
as necessary.- ERROR7 OK, 2 NOTE, 4 ERRORNow
- ERROR11 OK, 2 NOTE, 1 ERROR2026-03-10
Documentation
- Help pages
- 80
- Examples that run
- 33%3 run in a plain check (1 of them under a condition) · 6 never run
- Exported functions with examples
- 12%
- Documented parameters
- 98%
- Return-value docs
- 96%
- Help pages citing references
- 8%
- switchr basics2 PDF
Downloads
Repository
- PRs merged (all time)
- 50%
- Median days to close, 50 most recently updated closed issues
- 108
- Median days to close, 50 most recently updated closed PRs
- 2
Stars over time
Forks over time
Issues over time
PRs over time
1 development-tooling and community-health practice detected across 1 family in the upstream repository
Checks run against github.com/gmbecker/switchr on 2026-10-18.
Dependencies
Code & Tests
People & History
Pick two releases to compare their code metrics.
- RR 4.6.0 released · 2026-04-24
- RR 4.5.0 released · 2025-04-11
- RR 4.4.0 released · 2024-04-24
- RR 4.3.0 released · 2023-04-21
- unarchivedReturned to CRAN2023-03-21
- 0.14.8Latest
- archivedRemoved from CRAN2023-03-01issues were not corrected despite reminders
- RR 4.2.0 released · 2022-04-22
- 0.14.5
- RR 4.1.0 released · 2021-05-18
- RR 4.0.0 released · 2020-04-24
- 0.14.32020-04-20 · diff ↗
- unarchivedReturned to CRAN2020-01-26
- 0.14.2
- archivedRemoved from CRAN2020-01-22check issues were not corrected in time Tries to access cran.usthb.dz which fails from time to time
- RR 3.6.0 released · 2019-04-26
Show 21 earlier eventsHide 21 earlier events
- 0.13.5
- 0.13.02018-08-25 · diff ↗
- RR 3.5.0 released · 2018-04-23
- unarchivedReturned to CRAN2018-02-22
- 0.12.72018-02-22 · diff ↗
- archivedRemoved from CRAN2018-02-21check problems were not corrected despite reminders Unconditional use of Suggests package(s) from BioC Attempt to use defunct BioC 'extra' repository
- 0.12.62017-11-07 · diff ↗
- 0.12.52017-11-06 · diff ↗
- RR 3.4.0 released · 2017-04-21
- 0.11.2
- 0.11.02016-10-25 · diff ↗
- 0.10.142016-05-22 · diff ↗
- 0.10.13
- RR 3.3.0 released · 2016-05-03
- 0.9.192015-09-17 · diff ↗
- 0.9.18
- 0.9.10
- 0.9.6
- 0.9.42015-06-06 · diff ↗
- 0.9.32015-06-03
- RR 3.2.0 released · 2015-04-16
Package metadata
- First published
- 2015-06-03
- Total releases
- 19 / 11 yrs
- License
- Artistic-2.0 OSI
- Copyright
- Genentech Inc
- Download size
- 618 KB
Cite
Cite this package
Run in R for the authors' entry:
citation("switchr")The package provides a citation file, so citation() returns the authors' own entry.
It points to 10.18637/jss.v082.i01.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.