Data In The Wild
  1. Module 1
  2. Assignment 3
  • 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 Description
    • Purpose
    • Task
    • Criteria for Success
  • Assignment Questions
    • Bonus! (up to 2 points)
  • Turning in Your Assignment
  1. Module 1
  2. Assignment 3

Module 1, Assignment 3: Getting to Know Your Home

Author

Ellen Bledsoe, Lily McMullen

Assignment Description

Purpose

The goal of this assignment is to get comfortable using the tidyverse with 2-dimensional data sets (data frames).

Task

Write R code using the tidyverse to successfully answer each question below.

Criteria for Success

  • Code is within the provided code chunks
  • 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

For this final assignment for Module 1, you’ll be working with another real-world data set: a collection of data from climate stations scattered across Antarctica.

  1. In your own words, describe what the tidyverse is. Your answer should be between 1-3 sentences.

    Answer:

  2. Load in the tidyverse package.

# Write your code here
  1. In your data folder, look for the data file called aggregated_station_data.csv and load it in using the read_csv() function. Save the data as an object called weather.
# Note: use the read_csv function, not the read.csv function!
# Write your code here
  1. Take a look at the data in whichever way you would like (looking in the environment, viewing the data, typing a function into the console below, etc.). How many rows and columns are in the data? Type your answers below:

    rows:
    columns:

# using code is optional for Question 4
  1. Write some code to choose rows that only include temperatures which are above freezing (AKA greater than 0 because the temperature is currently in Celsius)
# Write your code here
  1. Write some code to choose only columns with the following information: the year, day, month, temperature, and the station ID. Save these columns as a new object called station_temp.
# Write your code here
  1. Using the data frame you created in Q6 above (station_temp), add a new column to that data frame that converts the temperature column (currently in Celsius) to Fahrenheit. Call the new column tempF.

    Hint: we did this in class, use that same equation!

# Write your code here
  1. In your own words (either bullet points or sentence form is fine), explain two benefits of using the pipe (%>%).

    Answer:

  2. Using the original data frame (weather), find the minimum (min()) temperature recorded for each month (in Celsius, the original column).

    Hint: think about months first (split) and then temperature (apply). You will also want to remove all the NA values.

# Write your code here
  1. Again, using the original data frame, produce a data frame with the average temperature in the month of January for each station.

    Some hints:

    • take note of how months are represented in the data

    • think about using the pipe, how we choose which rows we want, and how we split-apply-combine

    • remember to remove the NA values!

# Write your code here

Bonus! (up to 2 points)

Write code to determine how many unique stations are in the weather data set. (Hint: look up the help files for the distinct() and the count() functions).

# Write your code here

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