Chapter 7 CHECK PACKAGE

Source: https://vbaliga.github.io/verify-that-r-packages-are-installed-and-loaded/

## If a package is installed, it will be loaded. If any 
## are not, the missing package(s) will be installed 
## from CRAN and then loaded.

## First specify the packages of interest
packages = c("tidyverse", "geomorph",
             "phytools", "viridis")

## Now load or install & load all
package.check <- lapply(
  packages,
  FUN = function(x) {
    if (!require(x, character.only = TRUE)) {
      install.packages(x, dependencies = TRUE)
      library(x, character.only = TRUE)
    }
  }
)

Cách này áp dụng để kiểm tra xem package đã có chưa thì cài đặt và loading.

Somasegaran, P., and H. J. Hoben. 1985. “Methods in Legume-Rhizobium Technology.”
Vries, Andrie de, and Joris Meys. 2015. R For Dummies. 2nd ed.