Skip to contents

This function checks if a specified package is installed. If the package is not installed, it installs the package from GitHub using the remotes package, and then loads it into the R session.

Usage

load_or_install_github(pkg, repo)

Arguments

pkg

A character string specifying the name of the package to be loaded or installed.

repo

A character string specifying the GitHub repository in the form "user/repo" from which to install the package.

Value

This function does not return a value. It is called for its side effect of loading or installing the package.

Details

The function first checks if the package is available in the current session using requireNamespace. If the package is not installed, it installs it from the specified GitHub repository using remotes::install_github, and then loads the package using library.

Examples

if (FALSE) { # \dontrun{
load_or_install_github("geneticMapR", "vegaalfaro/geneticMapR")
load_or_install_github("dplyr", "tidyverse/dplyr")
} # }