A software package is a distributable collection of source code, data, documentation, and supporting resources that extends a programming environment. In R, packages let programmers add capabilities beyond base R without changing its original code base. section 1.2.2 section 2.1
Use packages through a simple installation-and-loading workflow:
- Install a package once with base R’s install.packages() function, commonly using a package available from CRAN or occasionally GitHub. section 2.1
- Load the package whenever and wherever its functions will be used by calling library() before the rest of the script. section 2.1 section 3.2
- Use packages such as tidyverse, dplyr, tidyr, ggplot2, sqldf, patchwork, and networkD3 for wrangling, querying, visualization, and flow diagrams. section 2.1 section 3.2
- Load many packages sequentially with library(), or store their names in a vector and pass that vector to lapply(). section 3.2
Loading analysis tools
Install the tidyverse once, then load it before data preparation or visualization: install.packages("tidyverse"); library(tidyverse). A larger script can instead use packages <- c("tidyverse", "networkD3", "patchwork") followed by lapply(packages, library, character.only = TRUE). section 2.1 section 3.2
Browse the CRAN package-count figure to see the expanding ecosystem of available R packages. section 1.2.2







