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.
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.
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.
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:
state
: The state abbreviation.pop_2020
: The population of the state in 2020.pop_2010
: The population of the state in 2010.seats_2020
: The number of seats apportioned to the state in 2020.seats_2010
: The number of seats apportioned to the state in 2010.seats_1910
: The number of seats apportioned to the state in 1910.There are a series of variables in the states
data set, but the most important are follows:
STUSPS
: The state abbreviation.geometry
: sf
geometryThe Census data comes from the US Census.
The shapefile and other spatial analysis files also come from the US Census.
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.
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.
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!)
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
.
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.
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).Modify the us-plot-3
code chunk to create a plot of the seat change from 2010 to 2020, with districts colored according to seat_change_2010
. When making the scale, use informative colors, and set a midpoint at 0 (thus representing no change in the number of seats apportioned in each Census. When you are finished, remove eval = FALSE
.
Finally, please describe what patterns you observe in terms of which states gained and lost seats.
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…
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).Modify the us-plot-4
code chunk to create a plot of the seat change from 1910 to 2020, with districts colored according to seat_change_1910
. When making the scale, use informative colors, and set a midpoint at 0 (thus representing no change in the number of seats apportioned in each Census. When you are finished, remove eval = FALSE
.
Finally, please describe what patterns you observe in terms of which states gained and lost seats 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: