Learn R Programming

ProjectTemplate (version 0.11.0)

require.package: Require a package for use in the project

Description

This functions will require the given package. If the package is not installed it will stop execution and print a message to the user instructing them which package to install and which function caused the error.

Usage

require.package(package.name, attach = TRUE)

Value

No value is returned; this function is called for its side effects.

Arguments

package.name

A character vector containing the package name. Must be a valid package name installed on the system.

attach

Should the package be attached to the search path (as with library) or not (as with loadNamespace)? Defaults to TRUE. (Internal code will use FALSE by default unless a compatibility switch is set, see below.)

Details

The function .require.package is called by internal code. It will attach the package to the search path (with a warning) only if the compatibility configuration attach_internal_libraries is set to TRUE. Normally, packages used for loading data are not needed on the search path, but not loading them might break existing code. In a forthcoming version this compatibility setting will be removed, and no packages will be attached to the search path by internal code.

Examples

Run this code
library('ProjectTemplate')

if (FALSE) require.package('PackageName')

Run the code above in your browser using DataLab