Today you’re going to apply the data wrangling and visualization concepts you learned today to a real coral reef dataset from Mo’orea. You’ll also learn how to load external data.
Background
This dataset comes from the Moorea Coral Reef Long Term Ecological Research (MCR LTER) site in French Polynesia, one of the longest-running coral reef monitoring programs in the world. Since 2005, researchers have surveyed the benthic (bottom-dwelling) community at six fixed sites spaced around the island of Moorea. At each site, two habitats are monitored every year: the fringing reef, a shallow zone close to shore, and the forereef, a deeper zone on the outer slope of the reef, beyond the reef crest.
At each site and habitat, divers lay out permanent transects on the reef and photograph a series of quadrats (small square sampling frames) along them every year. Back in the lab, every point in each quadrat photo is classified into a taxonomic or substrate category — a coral genus (e.g., Acropora, Pocillopora, Porites), an algae type, sand, or another functional group — and the percent of the quadrat covered by each category is calculated. Because the same transects and quadrats are resurveyed annually, this design lets researchers track how coral cover changes over time, including before and after disturbances like cyclones and bleaching events.
The columns you’ll use most are:
Site: one of six fixed LTER sites around Moorea (LTER_1–LTER_6)Habitat:Fringing(shallow, nearshore) orForereef(deeper, offshore)Depth: survey depth, in metersDate: survey year and monthTaxonomy_Substrate_or_Functional_Group: the coral genus or substrate/algae category identified in a quadratPercent_Cover: the percent of a quadrat covered by that category
Read data
Download the data from here.
Inside your day 6 folder, create a subfolder called data.
Put moorea_coral.csv in your data folder.
Create a Quarto document in your day 6 folder called wrangle-visualize-coral.qmd.
Add a code chunk containing the following code:
library(tidyverse)
moorea_coral <- read_csv(
"data/moorea_coral.csv",
na = c("", "NA", "ND") # This vector tells read_csv() which values to interpret as missing data
)Use glimpse() to see what the dataset looks like.
Wrangle and visualize
Exercise 1
- Filter the data to the LTER 1 site in 2017, keeping only the taxa Acropora and Pocillopora.
- Rename
Taxonomy_Substrate_or_Functional_Groupto something shorter and more descriptive. - Make a boxplot showing the distribution of the percent cover, by habitat (fringing vs. forereef) and species.
- Clean up the scale titles.
Exercise 2
- Continue using the filtered data from the previous exercise.
- Divide the percent cover by 100 so it’s expressed as a fraction.
- Calculate the mean and standard deviation of percent coral cover by habitat, depth, and taxon.
- Sort the output in order of depth and taxon.
Exercise 3
Use markdown in your Quarto document to explain your findings from Exercises 1 and 2.
Bonus exercise
Use the distinct() function to find all unique taxa, then sort by taxa. What do you notice about Porites?
Use the ifelse() and str_starts() functions to combine all the Porites values into a single label. Then repeat your analysis from Exercise 2, but this time expand your analysis to include Porites and Montipora. Hint: use the %in% operator.
What coral is most widespread in the fringing reef, nearest the island? What about further offshore in the forereef?