how to install a package in r

To install a package in R, you can use the install.packages() function followed by the name of the package you want to install. For example, to install the tidyverse package:

main.r
install.packages("tidyverse")
30 chars
2 lines

Once the package is installed, you can load it into your R session using the library() function:

main.r
library(tidyverse)
19 chars
2 lines

If the package is not available in the default repository (CRAN), additional repositories can be added using the setRepositories() function.

related categories

gistlibby LogSnag