Lab #04: Team Workflow & Spatial Data

due Sun, Feb 14 11:59 PM

Goals

Getting started

Check the announcement on Sakai to determine your team number and members. When the lab TA opens breakout rooms, join the appropriate numbered room (so Team 05-1 joins breakout room 1, Team 05-2 joins breakout room 2, etc).

Before getting started on the lab, take a few minutes to develop a plan for working as a team for the rest of the semester.

Every team member should now go to the course GitHub organization and locate your lab04 repository, which should have the prefix lab04. Copy the URL of the repository and clone in RStudio. If you have trouble, see the first lab and lecture for step-by-step instructions or ask a teammate for help.

Do not edit the .Rmd file until explicitly asked to do so in the instructions.

Florida Voting

In this lab you will use the sf package to visualize county-level election results in Florida for the 2016 and 2020 U.S. Presidential elections. The fl_votes data contains the variables below.

Variable Description
county Florida county
rep16 votes cast for the Republican candidate (Donald Trump) in the 2016 Presidential election
dem16 votes cast for the Democratic candidate (Hillary Clinton) in the 2016 Presidential election
rep20 votes cast for the Republican candidate (Donald Trump) in the 2020 Presidential election
dem20 votes cast for the Democratic candidate (Joe Biden) in the 2020 Presidential election
geometry sf geometry

Team workflow

Assign each team member a number 1 through 3 and write your number down on a piece of paper. If you have four team members the fourth member should read the problem prompts and check that all members are following the instructions. This lab will walk you through the basics of team workflow step-by-step.

Do the following exercises in order, following each step carefully.

Only one person at a time should type in the .Rmd file and push updates.

The person working should share their screen and the others should follow along.

Team member 1: Open the lab04.Rmd file and change the author of the YAML header to the following “Team Number: Member 1, Member 2, Member 3” with your team number (for example 05-1) and the first and last names of all team members.

Team member 1: Run the load-data code chunk to read in the data and print the first six rows. Share the results with your team members. Then, answer the questions below.

  1. Is fl_votes “tidy”? Why or why not?

  2. Modify the add-winner code chunk to mutate() a new variable winner20 describing who won each Florida county in the 2020 Presidential election. The function if_else will be helpful. if_else(condition, true, false) assigns true if the first condition is TRUE and assigns false if the first condition is FALSE. When you are satisfied, remove eval = FALSE in the add-winner code chunk.

Team member 1: When you have finished, knit to PDF, then stage, commit, and push your .Rmd and PDF to GitHub with an appropriate commit message.

All other team members: Once your team member has pushed the work, pull to get the updated documents from GitHub. Click on the .Rmd file and you should see the responses to the first two exercises. Run the code chunks for #1 and #2 to update fl_votes in your environment.

Team member 2: It’s your turn. Answer the questions below.

  1. Modify the fl-plot-1 code chunk to create a plot of Florida’s 2020 U.S. Presidential election results by county, with counties colored by winner20. Use informative colors with the scale_fill_manual() function. The colors “#DE0100” and “#0015BC” look good for Republicans and Democrats, respectively, but the choice is yours. When you are finished, remove eval = FALSE.

Team member 2: Knit to PDF, then stage, commit, and push your .Rmd and PDF to GitHub with an appropriate commit message.

All other team members: Once your team member has pushed the work, pull to get the updated documents from GitHub. Click on the .Rmd file and you should see the responses to the first three exercises. Run the code chunks for #1, #2, and #3 to update fl_votes in your environment.

Team member 3: It’s your turn. Complete the exercises below.

  1. Create two new variables using mutate() in the fl-props code chunk. prop_rep16 is the Republican share of the two party vote in the 2016 Presidential election and prop_rep20 is the Republican share of the two party vote in the 2020 Presidential election. When you are finished, remove eval = FALSE.

  2. Modify the fl-plot-2 code chunk to create a plot of 2020 U.S. Presidential results by county, with counties colored according to the proportion of the two party vote cast for the Republican candidate. The scale_fill_gradient() function will be helpful for effective coloring (but there are other possibilities). When you are finished, remove eval = FALSE.

Team member 3: Knit to PDF, then stage, commit, and push your .Rmd and PDF to GitHub with an appropriate commit message.

All other team members: Once your team member has pushed the work, pull to get the updated documents from GitHub. Click on the .Rmd file and you should see the responses to the first five exercises. Run the code chunks for #1 - #5 to update fl_votes in your environment.

Team member 1: It’s your turn. Complete the exercises below.

  1. Create a new variable diff_rep using mutate() in the fl-change code chunk, representing the change in the two party vote share between 2016 and 2020 (prop_rep20 - prop_rep16).

  2. Modify the fl-plot-3 code chunk to plot the change in Republican vote share by county between 2016 and 2020. The scale_fill_gradient2() function will be helpful for effective coloring. When you are finished, remove eval = FALSE.

Team member 1: Knit to PDF, then stage, commit, and push your .Rmd and PDF to GitHub with an appropriate commit message.

All other team members: Once your team member has pushed the work, pull to get the updated documents from GitHub. Click on the .Rmd file and you should see the responses to the first seven exercises. Run the code chunks for #1 - #7 to update fl_votes in your environment.

Team member 2: Almost done! Examine the three visualizations on your PDF and discuss with your group. Then, answer the question below.

  1. What do the visualizations you developed tell you about the 2016 and 2020 Presidential election in Florida? What are limitations of these visualizations? You may need to do a little bit of research if you aren’t familiar with Florida or American politics.

Team member 2: Check to confirm all code chunks are named, code does not exceed the 80 character limit and all code follows the tidyverse style guidelines. Make changes as necessary.

Team member 2: When you have finished, knit to PDF, then stage, commit, and push your .Rmd and PDF to GitHub with an appropriate commit message.

All other team members: Once your team member has pushed the work, pull to get the updated documents from GitHub. Click on the .Rmd file to see your final version of the lab.

Team member 3: Upload your team’s PDF to Gradescope. Include every team member’s name in the Gradescope submission and identify which problems are on each in Gradescope. Associate the “Overall” section with the first page of your PDF.

There should only be one submission per team on Gradescope.