Lab 04: Team workflow and spatial data

Due: Thu, Feb 18 at 11:59pm ET

Goals

Getting started

Check the #lab channel in Slack to identify your team name and teammates. Join the appropriate breakout room in Zoom. If you have not updated Zoom, the TAs will place you in the correct room.

Follow the slides as the TAs demonstrate an effective team-based workflow. Today’s lab will be very structured since it is your first time using git/GitHub as a team.

Every team member should go to the course GitHub organization and locate your lab_04 repository, which should be named lab_04-<team name>. Copy the URL of the repository and clone it to RStudio. If you have trouble, see the first lab and lecture for step-by-step instructions or ask a teammate for help. If you cannot find your lab 04 repository, verify your GitHub username in the CSV file on Slack is correct. If it is incorrect or missing, message the instructor with your team name and GitHub username immediately.

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.

Team workflow

Assign each team member a number, 1 through 3. 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 lab_04.Rmd file and change the author of the YAML header to the following “Team: Member 1, Member 2, Member 3” with your team name 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 the 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 which page in Gradescope. Associate the “Overall” section with the first page of your PDF.

There should only be one submission per team on Gradescope.