Packages

In computer programming, a package is a collection of modules or programs that are often published as tools for a range of common use cases, such as text processing and doing math. Programmers can install these packages and take advantage of their functionality within their own code.

This page includes instructions for installing packages in R and a description of some of R's most frequently used packages.

Installing Packages

To install a package in R, you can either:

  • Use the install.packages("PackageName") function if you have the package downloaded locally on your machine

  • Or if you are using RStudio, you can use Tools > Install packages, enter in the package name and click Install

Once you install the package, you have to load it into your library using the libary(PackageName) function.

#Installing a package downloaded locally
install.packages("tidyverse")

#Once the package is installed, you have to load it
library(tidyverse)

Helpful Packages

In R, tidyverse is one of the most popular packages, as it contains an assortment of packages used for data science, such as:

  • ggplot2, used to create graphics and data visualization

  • dplyr, contains functions used for data manipulation, like mutate() and filter()

  • tidyr, used for data organization and cleaning

  • tibble, an optimized dataframe visualizer

  • readxl, can be used to input Excel files in .xlsx format into R

Resources

Last updated