Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

is_installed

Are packages installed in any of the libraries?


Description

These functions check that packages are installed with minimal side effects. If installed, the packages will be loaded but not attached.

  • is_installed() doesn't interact with the user. It simply returns TRUE or FALSE depending on whether the packages are installed.

  • In interactive sessions, check_installed() asks the user whether to install missing packages. If the user accepts, the packages are installed with pak::pkg_install() if available, or utils::install.packages() otherwise. If the session is non interactive or if the user chooses not to install the packages, the current evaluation is aborted.

Usage

is_installed(pkg)

check_installed(pkg, reason = NULL)

Arguments

pkg

The package names.

reason

Optional string indicating why is pkg needed. Appears in error messages (if non-interactive) and user prompts (if interactive).

Value

is_installed() returns TRUE if all package names provided in pkg are installed, FALSE otherwise. check_installed() either doesn't return or returns NULL.

Examples

is_installed("utils")
is_installed(c("base", "ggplot5"))

rlang

Functions for Base Types and Core R and 'Tidyverse' Features

v0.4.11
MIT + file LICENSE
Authors
Lionel Henry [aut, cre], Hadley Wickham [aut], mikefc [cph] (Hash implementation based on Mike's xxhashlite), Yann Collet [cph] (Author of the embedded xxHash library), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.