groundhog.library {groundhog}R Documentation

Install & load CRAN, GitHub, and GitLab packages as current on given date

Description

Load requested package(s) as current on a requested date. If the needed version of a package, or its dependencies, is not already installed, groundhog automatically installs it. groundhog.library() thus substitutes both library() and install.packages(). There is no change in setup or configuration parameters needed to start using groundhog; simply edit your script going between library() and groundhog.library() as needed. Groundhog often installs/uninstalls packages in the default personal library. These changes can be reversed in a few seconds, with restore.library()

Usage

groundhog.library(
  pkg,
  date,
  quiet.install = TRUE,
  include.suggests = FALSE,
  ignore.deps = c(),
  force.source = FALSE,
  force.install = FALSE,
  force.source.main = FALSE,
  force.install.main = FALSE,
  tolerate.R.version = "",
  cores = -1
)

Arguments

pkg

character string or vector with name of package(s) to load/install.

date

character string (yyyy-mm-dd), or date value, with the date which determines the version of the package, and all dependencies, to be loaded (and installed if needed). The most recent date accepted is 2 days prior to when the code is executed.

quiet.install

logical, defaults to TRUE. When set to FALSE, displays output generated by install.packages() when installing from source

include.suggests

logical, defaults to FALSE. When set to TRUE, loads dependencies classified in the DESCRIPTION file as suggested.

ignore.deps

an optional character vector containing dependencies which are already loaded in the R session, and create a conflict with a needed dependency for the package being loaded (mismatch of version), but which should be ignored and groundhog.library() should proceed tolerating the conflict.

force.source

logical (defaults to FALSE). When set to TRUE, if the requested package, or its dependencies, needs to be installed, they will be installed from source (much slower than from binaries).

force.install

logical (defaults to FALSE). When set to TRUE, will re-install the requested packages and their dependencies even if they are already installed.

force.source.main

logical (defaults to FALSE). When set to TRUE, if the requested package needs to be installed it will be installed from source (but dependencies are installed from binaries if needed and available).

force.install.main

logical (defaults to FALSE). When set to TRUE, will re-install the requested packages even if they are already installed (but dependencies will not be re-installed).

tolerate.R.version

optional character string containing an R version which groundhog.library() will not throw an error for using, even if the date entered corresponds to a more recent major R release.

cores

Integer. The maximum number of cores to use during parallel installation of source packages. The default, -1, uses the total number of cores available minus 1. Setting core=1 leads to installing source packages, and also to downloading binaries, sequentially. When installation fails, you may want to try cores=1

Details

For more information about groundhog check out groundhogr.com

Examples

## Not run: 
groundhog.library("magrittr", "2022-04-15")

pkgs <- c('pwr','metafor')
groundhog.library(pkgs, "2022-04-15")

# When running an existing  script that relied on `library()` to load packages,
# you can wrap the library calls in double-quotes, loading the packages with 
# groundhog:

  groundhog.library(
       "
        library('pwr')
        library('metafor')
        library('tidyr')
        library('rio')
        library('this.path')
       "
       ,'2022-04-01')

#Allow using R 3.6.3 despite entering a date that corresponds to R >=4.0.0
  groundhog.library('rio', '2022-04-11', tolerate.R.version='3.6.3')


## End(Not run)


[Package groundhog version 3.2.0 Index]