Packages & Libraries

Installation versus Loading

Packages must first be installed before they can be loaded. Installing a package is equivalent to going to a hardware store and buying a pre-made set of tools whereas loading that package is more like retrieving a set of tools that you already own and putting them in your work space so they are available to use. All sections of this website assume you have already installed the needed packages so consult the package installtion instructions on the home page of the site if you have not already done so.

Note also that “package” and “library” are functionally interchangeable for our purposes though it is more common to say that packages are installed and libraries are loaded.

Library Loading

Assuming you’ve already installed the needed Python and R packages, you can now load them.

R libraries are loaded with the library function.

library(tidyverse)

Python libraries are loaded with the import statement and can be “aliased” into simpler names with as at the same time. Note that common libraries (like pandas) have broadly-accepted abbreviations that are almost always used (like pd in the case of pandas).

import pandas as pd

With that, you’re all done loading libraries! Note however that you will need to re-load your libraries every time you quit and re-open your IDE (Integrated Developer Environment) such as Conda or RStudio. Restarting your session will also necessitate re-loading your libraries. That said, you only need to install packages once!