> For the complete documentation index, see [llms.txt](https://docs.bcbi.brown.edu/codiac-for-health/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bcbi.brown.edu/codiac-for-health/computing/r/packages.md).

# Packages

<mark style="color:$primary;">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.</mark>&#x20;

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 library(PackageName) function.

```r
#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:&#x20;

* [ggplot2](https://ggplot2.tidyverse.org), used to create graphics and data visualization
* [dplyr](https://dplyr.tidyverse.org), contains functions used for data manipulation, like mutate() and filter()
* [tidyr](https://tidyr.tidyverse.org), used for data organization and cleaning
* [tibble](https://tibble.tidyverse.org), an optimized dataframe visualizer
* [readxl](https://readxl.tidyverse.org), can be used to input Excel files in .xlsx format into R

## Resources

* R Documentation: [Packages](https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Packages)
* [Tidyverse](https://www.tidyverse.org)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.bcbi.brown.edu/codiac-for-health/computing/r/packages.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
