3.1 Core R Packages

On the lower right panel of your RStudio screen there is a tab labeled packages. If you click on the Packages tab, you see all of the packages that are stored on your computer for use in R. Some are loaded with the initial installation, but the power of R is in your ability to download additional packages.

If the boxes next to a particular package are not checked, the packages are stored on your computer, but are not currently loaded in your R workspace. To load the package into R, you just need to check the box on the left of the package you want to load.

Suppose you click on the box next to MASS. The result is shown in the Console in the lower left showing a command library().

library(MASS)

Of course instead of clicking the box for a particular package, you could just type library(nameofpackage) in the console.

This command (or sometimes now authors are showing require()) loads the package in your session so that it available for use. Note that unclicking this box unloads (or as R says, “detaches”) the package from your session. This action does not uninstall the package from your computer, but just removes the functions from the current workspace. If you want to delete a package, you click on the “x” that is to the right of the package (next to Version) in the Package tab in RStudio.

You can find help on the package by clicking on the package name.

Be aware that different packages have functions that are named the same. If you load both packages in the same session, the last one loaded will be the one used when you type in the function. Pay attention to the messages in the Console Window as the warning messages will indicate that a function will be masked.