Syntax

R Install and Load a Package Syntax

In R, install and load a package: installs and loads a package — install.packages("ggplot2") library(ggplot2)

Quick Answer

Syntax
install.packages("ggplot2") library(ggplot2)
RSyntax

Install and Load a Package

Code example
install.packages("ggplot2") library(ggplot2)

Installs and loads a package.

Learn More

How to install and load a package in R

  1. Open your R file or editor.
  2. Copy the example, then replace its sample names and values for your code.

R Install and Load a Package Syntax

Use install.packages("ggplot2") library(ggplot2).

Related Syntax References

Frequently asked questions

What is the R syntax for install and load a package?

Use this pattern: install.packages("ggplot2") library(ggplot2)

Can I copy this R code example?

Yes. Use Copy code and adapt the example to your program.

Is this R syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify