5 Data analysis and visualization in R

Written by Keaka Farleigh on August 5th, 2025

Last updated by Keaka Farleigh on August July 8th, 2025

5.1 Purpose

This tutorial will give you an introduction to data analysis and visualization. You will learn how to perform some basic analyses and how to visualize those results. I will assume that you have minimal experience with R and are a beginner user. Please read through the Introduction to R chapter or send me an email if you do not feel comfortable with this tutorial.

5.2 Learning objectives

  • Learn how to choose a statistical analysis.
  • Learn how to estimate correlation between two variables.
  • Learn how to perform linear regression.
  • Learn how to perform a t-test.
  • Learn best practices for plotting.
  • Learn how to make scatter plots.
  • Learn how to make boxplots.
  • Learn how to make a multipanel figure.

5.3 Files required for this pipeline

None!

5.4 Programs used in this pipeline

Install the tidyverse using the command below.

install.packages("tidyverse")

library(tidyverse)

5.5 Notes on this tutorial

The materials in this tutorial were originally developed as part of the Lambda bioinformatic workshop at Miami University by Dr. Tereza Jezkova and Dr. Alfredo Ascanio. These materials are now presented at Lambda and the Foundations in R workshop at the University of Virginia.

5.6 Overview

This tutorial will be broken into separate sections for data analysis and visualization, respectively. We will walk through the basics of analysis and visualization before working through some examples!

5.7 Data analysis

5.7.1 How to choose a statistical method

5.7.2 Correlation

5.7.3 Regression

5.7.4 T-test

5.8 Data visualization

5.8.1 Scatterplot

5.8.2 Boxplot

5.8.3 Multipanel figure

5.9 References

R Core Team (2025). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. https://www.R-project.org/.

Wickham, H., et al. (2019). Welcome to the tidyverse. Journal of Open Source Software, 4(43), 1686. https://doi.org/10.21105/joss.01686