deployrPackage: Install and load R packages to ensure package portability.

View source: R/deployrPackage.R

deployrPackageR Documentation

Install and load R packages to ensure package portability.

Description

The deployrPackage function guarantees package portability from your local environment to the DeployR server environment when you use it to declare all of the package dependencies in your R script.

This function safeguards your R code by making certain that the necessary packages are available to your R code at runtime.

For more information on ensuring package portability, see the ‘Writing Portable R Code’ document for your DeployR version on the official DeployR website (http://go.microsoft.com/fwlink/?LinkId=708337).

Usage

deployrPackage(pkgs, lib, repos = getOption("repos"), ...)

Arguments

pkgs

character vector of the names of packages whose current versions should be downloaded from the repositories. If repos = NULL, a character vector of file paths of .tar.gz files. If this is missing or a zero-length, character vector, a listbox of available packages is presented where possible in an interactive R session.

lib

character vector providing the library directories where to install the packages. Recycled as needed. If missing, defaults to the first element of .libPaths().

repos

character vector, the base URL(s) of the repositories to use, such as the URL of a CRAN mirror (for example: http://go.microsoft.com/fwlink/?LinkId=708336.) Can be NULL to install from local files (with extension .tar.gz for source packages).
Tip: If you develop your own private R packages and want to use them in DeployR, then we recommend storing these packages in a local CRAN repository that is reachable by the DeployR server. For more on setting up a local package repository, visit: http://cran.r-project.org/doc/manuals/r-release/R-admin.html.

...

additional arguments to pass to install.packages function.

Details

Declare the set of package dependencies using this function at the top of your script.

Packages declared using this function are automatically loaded at runtime, either in your local environment or on the DeployR server. The function checks whether the package is installed on the machine on which the script is running. If the package already exists, then it is loaded for you. If not found, the function attempts to install and load the package on your behalf. The deployrPackage function supports all the same arguments as the regular R install.packages function.

Note: If you declare your package dependencies with this function and your script still fails due to missing packages, please contact your DeployR server administrator with details.

Examples

## Not run: 
  
  ### PACKAGE DECLARATIONS ###
  # Use deployrPackage() to ensure package dependencies are 
  # installed & loaded at the start of your script.
  
  deployrPackage("ggplot2")

## End(Not run)


deployr/deployrUtils documentation built on July 5, 2023, 9:58 a.m.