1.9 Installing R packages

Let’s perform these two steps for the tidyverse package that was discussed earlier.

There are two ways to install an R package: an easy way and a more advanced way. Let’s install the ggplot2 package the easy way first as shown below.

1.9.1 The easy way:

  1. Go to the Files pane of RStudio:
  2. Click on the Packages tab.
  3. Click on Install next to Update.
  4. Type the name of the package under Packages (separate multiple with space or comma): In this case, type tidyverse.
  5. Click Install.
  6. Go ahead and install these additional packages:
    • questionr
    • skimr
    • foreign

Watch a video to show you how to install R packages.

1.9.2 The other way:

An alternative but slightly less convenient way to install a package is by typing install.packages(ggplot2) in the console pane of RStudio and pressing Return/Enter on your keyboard. Note you must include the quotation marks around the name of the package.

Much like an app on your phone, you only need to install a package once. However, if you want to update a previously installed package to a newer version, you must reinstall it by repeating the earlier steps.