Get startedGet started for free

Load an R Package

There are basically two extremely important functions when it comes down to using R packages:

  • install.packages(), which as you can expect, installs a given package.
  • library() which loads packages, making them available to use in your R workspace.

To install packages, you need administrator privileges. This means that install.packages() will not work in the DataCamp interface. However, the most popular CRAN packages are already installed on our servers. You can load them with library().

This exercise is part of the course

Intermediate R

View Course

Exercise instructions

  • Load the ggplot2 package; make sure you are loading (and not installing) the package!
  • Run ggplot(mtcars, aes(wt, hp)) + geom_point() to create a simple scatter plot and verify that ggplot2 is available.
  • Finally, use the search() function to list the packages that are loaded in your workspace.

Hands-on interactive exercise

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

# Load the ggplot2 package
___("___")

# Use ggplot2 to create a scatter plot
___

# Check out the currently attached packages again
___()
Edit and Run Code