Homework
This page contains instructions, deadlines, templates for assignments/peer reviews.
Overview:
All assignments should be created using RMarkdown and uploaded to Canvas as both html and Rmd files. Your document should be pleasant for a peer to look at and follow all instructions. Use sections for organization, label figures/tables, and use code chunks (e.g., echo
, results
).
Peer Review:
You are required to both grade and provide feedback on a peer's homework each week. Reading/evaluating the work of others is useful and important! Good programmers realize that most problems have been solved by others; the trick is figuring out how to apply existing code to new problems. You will develop this skill by reading others’ code, evaluating their approach to problems, providing suggestions, and pointing out when you learned something new. Good peer reviews give constructive, polite, and insightful comments, are specific and concise, use the grading rubric below, and point out what you learned from their code. Poor peer reviews are impolite or unprofessional, are generic (i.e., could be applied to anyone’s homework), or fail to provide useful suggestions.
Rubric Students Use to Grade Assignments:
0: Didn’t turn anything in
1: Turned in but low effort, ignoring many directions (less than 50% of assignment completed correctly)
2: Decent effort, followed directions with some minor issues (50-80% of assignment completed correctly)
3: Nailed it (>80% of assignment completed correctly)
Rubric Instructor Uses to Grade Peer Review:
0: Didn't follow all of the instructions below.
1: Peer review was at least one paragraph long, mentions any and all key issues from the assignment, and points out at least one thing positive in your peer's work (and hopefully more!).
When to Contact the Instructor:
A number of situations may warrant contacting the instructor:
- If you believe you have received an unfair peer review, you can resubmit your homework for evaluation by the instructor. The assignment will be regraded, which may result in a higher, same, or lower grade.
- If you wish for more feedback on a particular part of the homework, you can ask the instructor for additional explanation without resubmitting during lab or over email.
- If you receive no feedback, the instructor will provide gentle peer review on request.
Weekly Assignments:
Homework 1:
- Homework Instructions: Write up a .Rmd file showing some exploratory analyses of the Swiss fertility data. Upload both the .Rmd file and the .html
file to Canvas. You must upload both for credit.
Mix in-line R calculations, R output, and plots with text describing the relationships you see. Include at least two plots. You must use in-line R calculations at least once (e.g. functions likenrow()
,mean()
,sd()
,cor()
,median()
,min()
) and may not hard-code any numbers referenced in your text.
Your document should be pleasant for a peer to look at, with some organization using sections or lists, and all plots labeled clearly. Use chunk optionsecho
andresults
to limit the code/output you show in the .html. Discussion of specific values should be summarized in sentences in your text -- not as printed code and output -- and rounded so as not to be absurdly precise (e.g. round x withround(x, 2)
). - Homework Template:Rmd Template, html Template
- Homework Example: Rmd Example, html Example
- Homework Due Date: 4/5
- Peer Review Due Date: 4/10
Homework 2:
- Homework Instructions: In this homework, you'll pose a question regarding the Gapminder dataset and investigate it graphically.
- At the beginning of your document, write down a research question that is based on the Gapminder dataset (e.g., "How does population change over time in different countries?")
- Create 3-6 plots to answer/investigate your research question. Consider histograms (
geom_histogram()
), scatterplots (geom_point()
), or lineplots (geom_line()
). - Be sure all titles, axes, and legends are clearly labelled.
- Include at least one plot with
facet_wrap()
orfacet_grid()
.
.Rmd
file and the.html
file to Canvas. - Homework Example/Template: Rmd file, knitted html file
- Homework Due Date: 4/12
- Peer Review Due Date: 4/17
Homework 3:
- Homework Instructions: Create an RMarkdown file (from scratch this time!) in which you answer each of the following questions. Be sure to display all your code in the knitted version (use throughout
echo=TRUE
). Remember, the packagenycflights13
contains data on flights originating in NYC during the year 2013. There are three airports servicing NYC: JFK, LGA ("LaGuardia"), and EWR ("Newark").- Choose an airport outside New York, and count how many flights went to that airport from NYC in 2013. How many of those flights started at JFK, LGA, and EWR? (Hint: Use
filter
,group_by
, andsummarize
) - The variable
arr_delay
contains arrival delays in minutes (negative values represent early arrivals). Make a ggplot histogram displaying arrival delays for 2013 flights from NYC to the airport you chose. - Use
left_join
to add weather data at departure to the subsetted data (Hint 1: Match onorigin
,year
,month
,day
, andhour
!!). Calculate the mean temperature by month at departure (temp
) across all flights (Hint 2: Usemean(temp,na.rm=T)
to have R calculate an average after ignoring missing data values). - Investigate if there is a relationship between departure delay (
dep_delay
) and wind speed (wind_speed
). Is the relationship different between JFK, LGA, and EWR? I suggest answering this question by making a plot and writing down a one-sentence interpretation.
- Choose an airport outside New York, and count how many flights went to that airport from NYC in 2013. How many of those flights started at JFK, LGA, and EWR? (Hint: Use
- Homework Due Date: 4/19
- Peer Review Due Date: 4/24
- Homework Key: Rmd code and knitted html file.
Homework 4:
- Homework Instructions: Fill in the RMarkdown template below that walks you through the process of creating, accessing, and manipulating R data structures. Enter values in the RMarkdown document and knit it to check your answers!
- *Knit after entering each answer!!* If you get an error, check to see if undoing your last edit solves the problem. Coding an assignment to handle all possible mistakes is really hard!
- This assignment is also long, so *start early*.
- Homework Templates: Rmd example and knitted html file.
- Homework Key: Rmd code and knitted html file.
- Homework Due Date: 4/26
- Peer Review Due Date: 5/1
Homework 5:
- Homework Instructions: Fill in the RMarkdown template below that walks you through a real analysis of King County election data from 2016. In this homework, you will focus solely on a few importing, cleaning, and manipulation tasks using functions from the previous couple of lectures. Next week, we will continue our analysis!
- Homework Templates: Rmd template, and knitted html file
- Homework Key: Rmd code and knitted html file
- Homework Due Date: 5/3
- Peer Review Due Date: 5/8
Homework 6:
- Homework Instructions: This week, we'll continue our analysis of 2016 King County Election data. Fill out the template below.
- Homework Templates: Rmd version and knitted html version
- Homework Key: Rmd version and knitted html version
- Homework Due Date: 5/10
- Peer Review Due Date: 5/15
Homework 7:
- Homework Instructions: This week's homework will allow you to practice writing loops, functions, and `apply` commands. Please fill out the template below.
- Homework Templates: Rmd version and knitted html version
- Homework Key: Rmd version and knitted html version
- Homework Due Date: 5/17
- Peer Review Due Date: 5/22
Homework 8:
- Homework Instructions: In this week's homework, you'll practice working with both text data and mapping. Please fill out the template below.
- Homework Templates: Rmd version and knitted html version
- Homework Key: Rmd version and knitted html version
- Homework Due Date: 5/31
- Peer Review Due Date: 6/5 (11:59pm)
Homework 9 (Optional Extra Credit):
- Homework Instructions: For extra credit, you will revise and resubmit one of your previous homework assignments. You may gain up to 4 extra credit points. For each, please do the following:
- Write a 3 paragraph response to your initial assignment. The first paragraph should be a reflection of your peer reviewer's comments, if available (if not, compare your work to that which you were asked to peer review). The second paragraph should be a thoughtful explanation of your own work after viewing the key. What did you struggle with initially, and why? How could your initial work be improved? The third paragraph should provide a detailed description of what has been updated in your revised submission.
- Revise and resubmit your original work, being sure all requirements of the original assignment have been met and that all work appears professional and polished. Don't just copy the key, but provide an original submission in your own coding style.
- Submit the updated files on the Canvas assignment for Homework 9 (not the original assignment), being sure to add your written response at the beginning of your updated assignment .Rmd and .html files.
- Homework "Due" Date: 6/5 (11:59pm)
The text on this page has been adapted from previous course materials by Rebecca Ferrell, Charles Lanfear, and Breon Haskett.