How to Install a Package in R

In this tutorial, you will learn how to install a package in R.

TLDR solution

install.packages("package_name")

Step-by-Step Example

Step 1: Open R

Launch your R console or Rstudio.

Step 2: Install a package

Install the ggplot2 package by executing the following command in the console:

install.packages("ggplot2")

That's it! You just installed a package in R.