# R

R is a powerful programing language for data visualization and statistical analysis.&#x20;

## Installation

R can be installed standalone, but RStudio is highly recommended as a working environment. Be sure to [first install R](https://www.r-project.org/). On the left side of the web page you can install it from the CRAN mirror. After the install is complete, you can [install RStudio](https://posit.co/products/open-source/rstudio/).&#x20;

Alternatively, you can use R within Jupyter Lab. This is Aaron's preferred approach. See the next section on [How to set up your computer for NCIL Data Science](https://neurocognitive-imaging-lab.gitbook.io/ncil-lab-handbook/4KX9BrRxON7flu3dJyRM/computer-stuff/data-science-tools/jupyterlab-setup-on-your-computer).

## Recommended Packages and Resources

R packages can be installed in RStudio with `install.packages("package")` typed into the console. The [ggplot2](https://ggplot2.tidyverse.org/) R package is the gold standard for data visualization. For data manipulation, base R has many functions, but the [dplyr ](https://dplyr.tidyverse.org/)package increases the functionality for some applications. For simplicity, installing the entire collection of [tidyverse](https://www.tidyverse.org/) packages is another option, and can be done with `install.packages("tidyverse")`. It should also be noted that when using the packages, they must first be instantiated using at the beginning of the R file with `library("[package]")`

For learning how to use R, and R packages, Datacamp has multiple relevant courses - please see "[Learn some code](https://neurocognitive-imaging-lab.gitbook.io/ncil-lab-handbook/4KX9BrRxON7flu3dJyRM/computer-stuff/untitled)"

[*From Data to Viz*](https://www.data-to-viz.com/) is a fantastic web resource for data visualization using R, including code examples and graph ideas based on what type of data you have.
