Installing & Loading Packages in R
Base R is powerful, but Rβs real strength is the 20,000+ packages on CRAN. Everything below is a live R console β edit the code and press Run Code.
Watch: installing & loading packages
install.packages() once, library() each session, and package::function() to reach in for a single tool.
Download the R script Β· βΆ Practice in the playground β or edit and run each snippet below.
Install once, load each session
On your own machine you install a package once from CRAN, then load it whenever you need it:
install.packages("dplyr") # once, downloads from CRAN
library(dplyr) # every session, to use itLoad a package and use it
MASS ships with R. Loading it makes its datasets and functions available:
In this browser, packages are installed with webr::install() instead of install.packages(). The first Run Code below fetches MASS β give it 15β30 seconds.
Now its tools are yours
Reach for one function without attaching
package::function() uses a single function without library() β handy to avoid name clashes:
Your turn
Next: Your first plot β β turning data into pictures.