2 Packages

Packages are really important in R. They are collections of functions and/or data sets which you will only have access to when the specific package is installed and loaded into your RStudio session.

Before loading in a package to R, it must first be installed onto your device. You only need to install packages once and then they will always be ready to load into your current RStudio session. To install a package, we use the function install.packages("PackageName"), where "PackageName" is the case sensitive name of the package.

The textbook these labs are based on uses the PASWR2 package throughout. To install this package, run the following code.

install.packages("PASWR2")

Now that we have a package installed, we need to load it in to the current RStudio session in order to use any of the functions or access any of the data it contains. To load a package, we use the function library(PackageName). Note that this time we do not need to wrap PackageName in quotation marks.

To load in the PASWR2 package, run the following code.

library(PASWR2)

For more information on installing and loading packages, see Section 1.8 Packages in Probability and Statistics with R.