wb_require: Use Packages from Way-Back-Then

Description Usage Arguments Details Examples

Description

This function will make sure a specified package is available within the current R session. If the package is not available it will attempt to install it and load it thereafter. If its already installed it will only load the package.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
wb_require(
  pkg,
  library_path = getOption("wb_require_lib_path", NULL),
  date = getOption("wb_require_date", NULL),
  date_shift = getOption("wb_require_shift_date", NULL),
  package_path = getOption("wb_require_package_path", NULL),
  dependencies = getOption("wb_require_dependencies", c("Depends", "Imports",
    "LinkingTo")),
  url_fun = getOption("wb_require_url", wb_repo_url)
)

Arguments

pkg

character - package name specified as cha

library_path

character - lib_path to use first

date

character - date specified in ISO format, defaults to date specified in sessionInfo()$R.version$version.string

date_shift

integer - number of days to add to date

package_path

character - path to look for binary packages to install

dependencies

character vector - specifies which types of dependencies should be installed also

url_fun

function transforming a date into a repository url

Details

Other than the normal install.packages function this function will not use the newest package available but one that was available at a specific point in time on CRAN. For CRAN snapshots the Microsoft R Open snapshots and the checkpoint package are used.

The default date is the date of the release of the R version currently in use plus an additional 60 days.

The lib_path argument can be used to make use a project specific R package library path.

Also, its possible to specify a path were binary packages can be found and installed from.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 

# set options
options(wb_require_lib_path = "./r_lib_path")

# make sure package is available
wb_require("data.table")

# use packages released up to 365 days younger than the current R-versions
# release date
wb_require("data.table", date_shift = 365)

# use a specific lib path for loading and installing
wb_require("data.table", lib_path = "./r_lib_path")


## End(Not run)

petermeissner/wayback documentation built on Oct. 3, 2020, 6:01 a.m.