How to install and load a package in R language?

In R language, there are two functions that can be used to install and load a package.

  1. Installation package: Use the install.packages() function to install packages. For example, to install the package named “ggplot2”, you can use the following code:
install.packages("ggplot2")
  1. Load package: Use the library() function to load a package. For example, to load the recently installed “ggplot2” package, you can use the following code:
library(ggplot2)

This allows for installing and loading a package. If operating in RStudio, you can also directly install and load packages in the Packages panel.

Leave a Reply 0

Your email address will not be published. Required fields are marked *