Lab #04: Team Workflow & Spatial Data

due Friday January 28 at 9 AM

Goals

Getting started

Check the announcement on Sakai to determine your team number and members.

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.

The first team member (and only the first team member) should now accept the invitation for Lab 4 here https://classroom.github.com/a/zCh1yNiz and create a new team. Create it using your section number and group number. For example, if you are in the first section (01L) and are the second group, you should name your team Group 1-2.

This is what it should look like when the first group member accepts.

The second team member should now join the existing team. Click on the invitation (https://classroom.github.com/a/zCh1yNiz) and join your team- it is very important to pick the correct team at this point. Do not create a new team.

This is what it should look like for the second team member!

All other group members should now accept. It will look like this for them as well. Then, configure git in the console as we have done in previous labs, using your GitHub username and email address.

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

2020 Census and Reapportionment

In this lab you will use the sf package to visualize data related to the 2020 census and the reapportionment process.

The variables in the census file are as follows:

There are a series of variables in the states data set, but the most important are follows:

The Census data comes from the US Census.

The shapefile and other spatial analysis files also come from the US Census.

  1. Before getting started, please write a group contract on how you will work together as a team this semester…

Team workflow

Assign each team member a number 1 through 3 (or 4) and write your number down on a piece of paper. 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.

If you are working on any portion of the lab virtually, the person working should share their screen and the others should follow along.

Team member 1: Open the lab04-template.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. Join the states and census data sets to form a dataset called census_data. Then, for simplicity in this lab, please filter out Alaska, Hawaii, and Puerto Rico.

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 second exercise. Run the code chunks for #2 to update the file in your environment.

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

  1. Modify the us-plot-1 code chunk to create a plot of the 2020 Census population data by state. Give the plot an informative title, subtitle, and legend title. 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 #2 and #3 to update the file in your environment.

Team member 3: It’s your turn. Complete the exercises below. (If you have four team members, you could have person 3 do #4 and person 4 do #5. The main point is to make sure everyone is contributing!)

  1. Create a new variable using mutate() in the ex-4 code chunk.

Overwrite the census_data data set to add a variable that measures the change in population from 2020 in 2016 called pop_change. This variable should represent the percentage change in population in 2020 compared to 2010. When you are finished, remove eval = FALSE.

  1. Modify the us-plot-2 code chunk to create a plot of the population percentage change from 2010 to 2020, with districts colored according to pop_change. Use informative colors with the scale_fill_gradient2 function. Please set a midpoint at 0% population change. When making the scale, use informative colors, and set a midpoint at 0 (thus representing no change from 2010 to 2020.) When you are finished, remove eval = FALSE. Please describe what you observe. What regional patterns are present? Did some states lose population?

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 - #4 to update the file in your environment.

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

  1. Now, we are going to compare the change in seats apportioned to each state from 2010 to 2020. First, I would like you to create a new variable called seat_change_2010 that measures the increase in seats apportioned to a state in 2010 compared to 2010 (a negative value would indicate seats lost).

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 five exercises. Run the code chunks for #1 - #4 to update the file in your environment.

Team member 2: Almost done! Just one more question…

  1. Finally, we are going to compare the change in seats apportioned to each state from 1910 to 2020. First, I would like you to create a new variable called seat_change_1910 that measures the increase in seats apportioned to a state in 2020 compared to 1910 (a negative value would indicate seats lost over this 110 year period).

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.

Rubric: