need: Check if a package is installed and stop if not

View source: R/utils.R

needR Documentation

Check if a package is installed and stop if not

Description

If the package is not installed then the function will error and give an appropriate message.

Usage

need(package)

Arguments

package

a package name as a character string.

Details

Designed to be used in scripts or functions where a function from the named package is used with :: without attaching the package. It should be used alongside library() calls at the top of scripts where it also serves the purpose of indicating to the user that a package is needed.

The function uses requireNamespace() which will load the package if available but not attach it. This is what happens when :: is used.


jedwards24/edwards documentation built on Sept. 2, 2023, 8:16 a.m.