Learn R Programming

SimDesign (version 2.27)

CheckPackages: Check whether package versions are as expected

Description

Check if a specific version of a package is installed, and throw an error if not what was anticipated. Particularly useful when submitting jobs to cluster compute nodes where package versions may be been updated inadvertently.

Usage

CheckPackages(...)

Value

invisible return of the package names as a character vector

Arguments

...

character vectors indicating package and version to check, of the form "package OPERATOR version", where "OPERATOR" is one of R's logical expressions (e.g., "dplyr == 1.2.1"). Can contain one or more expressions to evaluate

Examples

Run this code

if (FALSE) {

  CheckPackages('dplyr == 1.2.1') # fails if not exact version
  CheckPackages('dplyr <= 1.2.1') # fails if not equal to or less than
  CheckPackages('dplyr >= 1.2.1') # allows specific version or higher

  CheckPackages('dplyr <= 1.2.1', 'mirt >= 1.45.1')  # multiple checks

}

Run the code above in your browser using DataLab