Search⌘ K

What are R Packages?

Explore the concept of R packages and their role in extending R's functionality. This lesson helps you understand how to install, load, and use packages like ggplot2 and dplyr in RStudio, ensuring you can effectively use the tools needed for data analysis.

Another point of confusion with many new R users is the idea of an R package. R packages extend the functionality of R by providing additional functions, data, and documentation. They’re written by a worldwide community of R users and can be downloaded for free from the internet.

For example, among the many packages we’ll use in this book is the ggplot2 package (Wickham et al., 2019a) for data visualization, and the dplyr package (Wickham et al., 2019b) for data wrangling. We’ll also use the moderndive package (Kim and Ismay, 2019) and the infer package (Bray et al., 2019) for tidy and transparent statistical inference.

A good analogy for R packages is that they’re like apps we can download on a mobile phone:

Analogy of R vs. R packages.
Analogy of R vs. R packages.

So R is like a new mobile phone, and while it has a certain amount of features when we use it for the first time, it doesn’t have everything. R packages are like the apps we can download on our 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 we’ve purchased a new phone, and we’d like to share a photo we’ve just taken with our friends on Instagram. We need to: ...