Online training class for Clinical R programming batch starts on Monday, 02Feb2026.
Click here for details.
Load an R package (library)
- After installing a package, we must load it into the current R session to use its functions
- library() attaches the package so its functions are available without prefix
- Think of this like making a SAS format catalog available using a LIBNAME—once attached, we can use its contents directly
- Basic usage
library("tidyverse") loads dplyr, ggplot2, readr and friends
- If the package is not installed,
library() throws an error
- Quiet loading (optional)
suppressPackageStartupMessages(library("tidyverse")) to hide startup messages
- Install-if-missing pattern (optional)
if (!require("tidyverse")) install.packages("tidyverse"); library("tidyverse")