Installing Packages


In order to use the tidyverse and any other package that is not included in Base R, we must learn to install packages. These packages that we install contain unique functions, tools, code, data and even examples.

The easiest way to install packages is to use the command:

install.packages()

For example, go ahead and install the tidyverse package on your own:

install.packages("tidyverse")

Calling Installed Packages

Once we have installed packages, we must call them into R in order to use them. This must be done each time you start a new document or R session. We call packages with the following command:

library(tidyverse)
## Loading tidyverse: ggplot2
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag():    dplyr, stats

When we call this package we can see that it has loaded into R. The first lines explain what has been loaded. Then what follows are conflicts.

What are Conflicts?

Conflicts happen when packages have functions with the same names as other functions. This is OK when you prefer the function in a package like tidyverse rather than some other function. Basically the last package loaded in will mask over other functions if they have common names.

We can see a further example of this below:

library(MASS)
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select