Overview

Please provide a reproducible .R script that answers all questions below and produces all of your analysis and plots. Some reminders:

  • Reproducible: This means when I run your .R file, it will run all analyses and create all plots without errors, without me having to reset my working directory, and without forcing me to install anything on my machine (i.e., use the require(librarian); shelf(your packages, lib = tempdir()) approach as in the code block below). This also means there should be NO ERRORS when I run it!
  • Format: Answer each question with (commented) text and code.

Background

The Valles Caldera National Preserve is part of the National Parks. It’s the caldera of an old volcano in the Jemez Mountains of New Mexico, USA. It has some pretty interesting socio-ecological history. Part of that history is CRAZY overgrazing by sheep and cattle during Spanish and then American ownerships. This overgrazing resulted in massive plant biodiversity losses in the native grasslands and riparian areas in the Caldera. In the early 2000’s, some scientists established a grazing exclosure experiment along several of the riparian zones in the Caldera. Their goal was to see if excluding cattle or all ungulates (cattle, deer, and elk) would increase plant biodiversity in the riparian areas.

Some details on the data:

Column Name Description
year years 2002 - 2014
site unique code for each site/treatment
treatment treatment type. C = control, LE = livestock exclosure, UE = all ungulates exclosure
All other columns each column is a plant species, and values are number of observations per 300 points within each site.

Your assignment

  1. The site metadata column has too much information: we need to split the information up into separate columns of it out while retaining the unique identifier information. Revise the site column to be the first three characters in the current site column (e.g., the new site value for RS1C1 should be “RS1”), and create a new column named plotCode with the final 1 - 2 characters in the current site column (e.g., the plotCode value for RS1C1 should be “C1”). To be clear: when you’re finished with this problem, the metadata columns should be: year, site, plotCode, and treatment.

  2. Create a Richness_total column by calculating total species richness for each row, and create an Diversity_InvSimp column by calculating Inverse Simpson’s Diversity Index for each row. Hint: for the Inverse Simpson’s, check out the vegan::diversity function. Also, total species richness is the total number of species per row.

  1. Using boxplots and histograms, check for outliers in the total species richness and species diversity columns.

  2. Check for balance in the data across sites, years, and treatments. Hint: use the table function. Using commented text, say if data is balanced and if not, how so?

  3. Create plot(s) to check for relationships between response variables (richness, diversity) and predictor variables (year, site, treatment). Using commented text, describe potential relationships.

  4. Should we worry about collinearity in our predictor variables? Why or why not?

  5. Create plot(s) to check for a potential interaction between year and treatment. Using commented text, tell me why we should or shouldn’t consider this interaction?

# List of packages necessary to run this script:
require(librarian, quietly = TRUE)
shelf(tidyverse, sf, vegan, quiet = TRUE)

# Repo URL 
repo_url <- "https://raw.githubusercontent.com/LivingLandscapes/Course_EcologicalModeling/master/"

# Load riparian vegetation monitoring dataset:
dat <- 
  read_csv(paste0(repo_url, "data/rip.dat.02-14.csv"))