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:
- Go to the
Filespane of RStudio: - Click on the
Packagestab. - Click on
Installnext to Update. - Type the name of the package under
Packages (separate multiple with space or comma):In this case, typetidyverse. - Click
Install.
- Go ahead and install these additional packages:
questionrskimrforeign
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.
