# Write your code hereModule 1, Assignment 3: Getting to Know Your Home
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.
In your own words, describe what the
tidyverseis. Your answer should be between 1-3 sentences.Answer:
Load in the
tidyversepackage.
- In your data folder, look for the data file called
aggregated_station_data.csvand load it in using theread_csv()function. Save the data as an object calledweather.
# Note: use the read_csv function, not the read.csv function!
# Write your code hereTake 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- 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- 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 hereUsing 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 columntempF.Hint: we did this in class, use that same equation!
# Write your code hereIn your own words (either bullet points or sentence form is fine), explain two benefits of using the pipe (
%>%).Answer:
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
NAvalues.
# Write your code hereAgain, 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
NAvalues!
# Write your code hereBonus! (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 hereTurning in Your Assignment
- Make sure your name is filled in at the top of the document.
- 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.
- To download the HTML file from Posit Cloud, click the empty box to the left of it in the Files panel.
- Click the blue gear at the top of the Files panel and choose Export.
- Put your last name at the front of the file name when prompted, then click Download. The file is now in your Downloads folder.