SwimmingTheDataLake Easy library installing and loading | Swimming the Data Lake

Easy library installing and loading

jvera

2017/17/11

I tend to use package managers for library load and management: pacman

https://cran.r-project.org/web/packages/pacman/vignettes/Introduction_to_pacman.html

With pacman::p_load() instead of 5 lines of code to load 5 common packages, like this:

library(dplyr)
library(tidyr)
library(Hmisc)
library(magrittr)
library(janitor)

You can write one line

pacman::p_load(dplyr, tidyr, Hmisc, janitor, magrittr)

if the package is not available on the system, it will first install it (through install.packages), and only then try to load it again. Same as library installr

installr::require2

All of this, on the very first part of any R file.