Data In The Wild
  1. Module 3
  2. Assignment 2
  • Home
  • Contact Us
  • For Instructors

  • Module 1
    • Overview
    • 1.1: Introduction to R and RStudio
    • 1.2: Intro to Coding in R
    • 1.3: Introduction to the tidyverse
    • Assignment 2
    • Assignment 3
  • Module 2
    • Overview
    • 2.1: Good Food Gone Bad
    • 2.2: Plotting with ggplot2
    • 2.3: Data Visualization
    • 2.4: Exploring geom Functions
    • 2.5: Module 2 Wrap-Up
    • Assignment 1
    • Assignment 2
    • Assignment 3
  • Module 3
    • Overview
    • 3.1: Leopard Seals
    • 3.2: T-Tests
    • 3.3: Comparing (Multiple) Means
    • Assignment 1
    • Assignment 2
  • Module 4
    • Overview
    • 4.1: Combining Datasets (Joins & Binds)
    • 4.2: K-Nearest Neighbor
    • 4.3: Roads and Regressions
    • 4.4: Multiple Regression
    • 4.5: Writing Functions
    • Assignment 1
    • Assignment 2
    • Assignment 3
    • Assignment 4
  • Module 5
    • Overview
    • 5.1: Population Growth
    • 5.2: Sustainable Fishing
    • 5.3: Comparing Populations
    • Assignment 1
    • Assignment 2
    • Assignment 3
  • Final Project

  • Resources

On this page

  • Assignment Details
    • Purpose
    • Task
    • Criteria for Success
  • Assignment Questions
    • Set-Up
    • Fish
      • Conceptual
      • Numeric
      • Visual
      • Statistics
    • Seals
      • Conceptual
      • Numeric
      • Visual
      • Statistics
    • Decision-Making
  • Turning in Your Assignment
  1. Module 3
  2. Assignment 2

Module 3, Assignment 2: Comparing Multiple Means

Author

Ellen Bledsoe, Lily McMullen

Assignment Details

Purpose

The goal of this assignment is to assess your ability to compare multiple means numerically, visually, and statistically and interpret the results.

Task

Write R code which produces the correct answers and correctly interpret the results of visualizations and statistical tests.

Criteria for Success

  • Code is within the provided code chunks
  • Code is commented with brief descriptions of what the code does
  • Code chunks run without errors
  • Code produces the correct result
    • Code that produces the correct answer will receive full credit
    • Code attempts with logical direction will receive partial credit
  • Written answers address the questions in sufficient detail

Assignment Questions

In this assignment, we’re going to explore data from four bays down in Antarctica: Emperor Bay, Hope Bay, Iceberg Bay, and Sulzberger Bay.

We’ve assessed our fleet and feel like we have enough fishing boats to fish from two of the four nearby bays. How do we decide which two bays to fish?

First, we need to assess how many fish are in each bay. Then we will assess how many leopard seals hang around each bay. Based on these two aspects, we will make a determination for which two bays we can most safely fish and still get enough fish for the station.

Set-Up

  1. As always, our first order of business is to load the tidyverse and our data sets. For this assignment, we have two different data sets: one for our survey of fish amounts and one for seal observations. Read both of them into the workspace and name them fish and seals, respectively.

Fish

The first question we’ve been asked to tackle is if the four bays have different amounts of fish. Let’s find out.

Explore the data set by using your favorite function to look at the data frame (e.g., head(), str()).

Early last year, we had our fishers head out into each of the four bays every day for a month to sample fish. They sampled using 5 nets in both the morning and the afternoon. They recorded how many kilograms of fish they caught in each net. The two variables that we will be using to help us make our evaluation are bay and fish_kg.

Conceptual

  1. Write out our two hypotheses for these data.

    Null Hypothesis \(H_{0}\):
    Alternative Hypothesis \(H_{A}\):

Numeric

  1. Let’s first find out what the mean (average) and standard deviation (spread) of fish_kg is in each bay. Save this data in a new data frame called fish_summary.

Take a look at the values. Do you think the bays have different amounts of fish based on these values? Let’s keep exploring.

Visual

  1. Plot the fish data using a box-and-whisker plot. It doesn’t need to be fancy (no need to fix axis labels and such) but make sure your plot has the following:

    • data points overlaying the boxes
    • the points should be partially transparent and jittered

Statistics

  1. In our data set, which variable is the independent variable? Is it categorical or numeric? Which is the dependent variable, and is it categorical or numeric?

    Independent:

    Dependent:

  2. Run an ANOVA to determine if there is an overall difference in means in the four bays. Save the model as an object called fish_model, then display the results of the model using the summary() function. Remember, the syntax for the model is: dependent ~ independent

  1. Interpret the results of the model and answer the following questions (2 points):

    • What is the value of the test statistic?

    • What is our p-value?

    • Is our p-value higher or lower than our cut-off value of 0.05?

    • Write 2-3 sentences explaining what this result means. How do we interpret this value? What does it mean for our hypotheses?

      Answers:

  2. Run some code to compute pairwise comparisons.

  1. Write 2-3 sentences interpreting the pairwise comparisons. Which pairs of bays are significantly different from each other, if any?

    Answer:

Seals

Let’s do the same for our seal data. The seals data frame has data on how many seals were observed each day in each survey area of the bay. The columns we will be focusing on are bay and num_seals.

Conceptual

  1. Write out our two hypotheses for the seal data.

    Null Hypothesis \(H_{0}\):
    Alternative Hypothesis \(H_{A}\):

Numeric

  1. Calculate the mean and standard deviation for the number of seals in each bay. Save this to a new data frame called seal_summary.

Take a look at the values. Do you think the bays have different numbers of seals based on these values? Let’s keep exploring.

Visual

  1. Plot the seal data using a box-and-whisker plot. It doesn’t need to be fancy (no need to fix axis labels and such) but make sure your plot has the following:
    • data points overlaying the boxes
    • the points should be partially transparent and jittered

Statistics

  1. Run an ANOVA to determine if there is an overall difference in means in the four bays.

    Save the model as an object called seal_model, then display the results of the model using the summary() function.

    Remember, the syntax for the model is: dependent ~ independent

  1. Interpret the results of the model and answer the following questions (2 points):

    • What is the value of the test statistic?
    • What is our p-value?
    • Is our p-value higher or lower than our cut-off value of 0.05?
    • Write 2-3 sentences explaining what this result means. How do we interpret this value? What does it mean for our hypotheses?

    Answers:

  2. Run a line of code to compute pairwise comparisons.

  1. Write 2-3 sentences interpreting the pairwise comparisons. Which pairs of bays are significantly different from each other, if any?

    Answer:

Decision-Making

Think through our goals in doing this analysis.

We want to choose two out of four bays to fish in. We want bays that have enough fish to feed our station but the least number of leopard seals to keep our fishing crews as safe as possible.

  1. Based on all our results, which two bays do you think we should fish? Explain your rationale (2 points)

    Answer:

Turning in Your Assignment

  1. Make sure your name is filled in at the top of the document.
  2. Click the Render button at the top of this document. This will produce an HTML file that opens in a new tab and also saves to the Files panel on the bottom-right of your screen.
  3. To download the HTML file from Posit Cloud, click the empty box to the left of it in the Files panel.
  4. Click the blue gear at the top of the Files panel and choose Export.
  5. Put your last name at the front of the file name when prompted, then click Download. The file is now in your Downloads folder.

2026, University of Arizona & Lewis & Clark College

 
  • Made with Quarto