1.8 R packages
When installed, R has a lot of functionality. Still, people often want more functionality. You can add this by installing R packages. A good analogy for R packages is they are like apps you can download onto a mobile phone. You can download R packages written by a worldwide community of R users for free from the internet.
For example, you will download a set of several packages known as the tidyverse. Included are the ggplot2 package used for data visualization and the dplyr and tidyr packages used for data management (also known as data wrangling).
So R is like a new mobile phone: while it has a certain amount of features when you use it for the first time, it doesn’t have everything. R packages are like the apps you can download onto your phone from Apple’s App Store or Android’s Google Play.
Let’s continue this analogy by considering the Instagram app for editing and sharing pictures. Say you have purchased a new phone and you would like to share a photo you have just taken with friends on Instagram. You need to:
- Install the app: Since your phone is new and does not include the Instagram app, you need to download the app from either the App Store or Google Play. You do this once and you’re set for the time being. You might need to do this again in the future when there is an update to the app.
- Open the app: After you’ve installed Instagram, you need to open it.
Once Instagram is open on your phone, you can share your photos with your friends and family. The process is very similar to using an R package. You need to:
- Install the package: This is like installing an app on your phone. Most packages are not installed by default when you install R and RStudio. When you want to use a package for the first time, you need to install it first. Once you’ve installed a package, you likely won’t install it again unless you want to update it to a newer version.
- “Load” the package: “Loading” a package is like opening an app on your phone. Packages are not loaded by default when you start RStudio on your computer; you need to “load” each package you want to use every time you start R/RStudio.
