Get startedGet started for free

Importing R packages

Although base R comes with a lot of useful functions, you will not be able to fully leverage the full power of R without being able to import R modules developed by others. Imagine we want to do some great plotting and we want to use ggplot2 for it. If we want to do so, we need to take 2 steps:

  1. Install the package ggplot2 using install.packages("ggplot2")
  2. Load the package ggplot2 using library(ggplot2) or require(ggplot2)

In datacamp however, most packages are already installed and readily available. As such, you won't need to run install.packages()

This exercise is part of the course

Inferential Statistics

View Course

Exercise instructions

  • Load the ggplot2 package using the library function
  • Load the ggplot2 package using the require function

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# load the ggplot2 package using the library function

# load the ggplot2 package using the require function
Edit and Run Code