Lab 11: ANOVA
Learning Objectives
By the end of this lab, you should be able to:
- Use R to visualize and summarize numerical data across multiple groups.
- Evaluate whether one-way ANOVA assumptions appear reasonable using graphs and summary statistics.
- Perform and interpret a one-way ANOVA in R.
- Conduct and interpret Tukey post hoc comparisons after a significant ANOVA.
- Use and interpret the Kruskal-Wallis test as a nonparametric alternative to ANOVA.
- Communicate statistical conclusions in biological context.
Overview
In this lab, you will complete the ANOVA lab activity provided on the textbook website for The Analysis of Biological Data:
https://whitlockschluter3e.zoology.ubc.ca/RLabs/R_tutorial_ANOVA.html
The lab focuses on comparing the means of three or more groups using analysis of variance (ANOVA), a common method in biology for evaluating differences among treatments, categories, or populations.
You will use R to explore data visually, calculate summary statistics, test for overall differences among groups with one-way ANOVA, and conduct post hoc comparisons when appropriate. You will also use the Kruskal-Wallis test as a nonparametric alternative when ANOVA assumptions are not well met.
By the end of the lab, you should be able to run these analyses in R and interpret the results in biological context.
Lab Instructions
Getting started
-
Get the Lab Worksheet.
Pick up a physical copy of the lab worksheet, or print one if you are working outside of class.
Download Lab Worksheet (PDF, if needed) -
Open the Lab 11 Project on Posit Cloud
Go to Posit Cloud and login
Go to the Course Workspace
Click the Lab 11 ANOVA assignment project to make your own copy of the project.
-
Set up your project according to the Guidelines for Setting Up a Project for a Lab Activity
Make sure your project settings are set correctly
Create a new R script in your project and save it with a clear name such as `lab11-anova.R`. You will use this script to complete your work for the lab.
At the top of your script, run the provided data import script so the three datasets are loaded into your environment.
Inspect the three datasets in your Environment tab.
At this point, you should have:
- These instructions open in a web browser.
- Your Lab 11 project open in Posit Cloud in another browser window.
- Your Lab script open
- Three datasets in the RStudio Environment tab
- The Lab 11 worksheet in front of you.
Do not continue until all of the above steps are done.
Read the examples
-
Go the the ANOVA lab on the textbook website:
https://whitlockschluter3e.zoology.ubc.ca/RLabs/R_tutorial_ANOVA.html
-
Read the example analysis using the Titanic dataset.
This will show you the overview of how to conduct an ANOVA or similar test.
At this point, you do not need to run the example code analyzing the Titanic dataset.
All the code and its output is already shown on the website, so running the code yourself at this point would not be helpful.
Instead, read it and refer back to it as you answer the questions at the bottom of that page.
Answer the Questions
- Scroll to the bottom of the ANOVA page at the link above, find the Questions heading.
-
For each of the three questions:
- Read each question carefully before beginning.
- Create the requested graphs and summary tables.
- Run the appropriate statistical test in R.
- Interpret the output in plain language.
- State conclusions that answer the biological question.
- Write your answers on the worksheet.
When asked whether assumptions are met, use your graphs and summary statistics to support your reasoning.
Write clearly and keep your script organized so another person could follow your analysis.
Wrap-up and Submission
- Make sure your script is saved in your project on Posit Cloud.
- Show your handout to a Learning Assistant for a completion grade before you leave lab. You may do this as soon as you finish. Keep the handout for yourself.
- Follow any additional submission instructions provided by your instructor.

