Time for you to show me what you have learned since the midterm.
For you final exam, you will:
Write R code that will produce each of the maps and charts below pertaining to how changes to the borders of Tennessee’s U.S. House of Representatives districts in 2022 affected the proportions of white and minority residents in each district.
Write a short analysis indicating whether, in your view, the maps and charts provide evidence that racial gerrymandering took place.
Organize your maps, charts, conclusions and code in an R Markdown document.
Publish the document on RPubs.com
Submit the document’s RPubs.com URL. Use the Final Exam URL Dropbox link in the Week 15 area of the course D2L site.
Your grade will be determined by:
The accuracy and styling of your maps and charts. “Styling” means things like colors, titles and axis labels.
Your ability to control the format of your RPubs.com document - that is, to suppress warnings and messages and select which output to display.
Your ability to meet the assignment’s submission deadline.
How clearly and accurately you connect your maps and charts with your conclusion.
Importantly, the degree or direction of the conclusion you reach about whether racial gerrymandering occurred will have no impact on your grade whatsoever. Personally, I consider the results suggestive of race-based gerrymandering, but not definitively so, and I think much depends on one’s inital assumptions about what fair, just district borders ought to look like. Your conclusion is up to you, though, and I will respect it, regardless of whether it aligns with mine. I am evaluating how well you can reason, with data, about a newsworthy topic of the kind media professionals would encounter in real-world practice. I am not evaluating whether you end up reaching the same conclusion I did. This approach abides by MTSU’s policy on divisive concepts.
Read on for more details and itps about completing the assignment.
As I explained during Week 13’s lesson on election data analysis, state and federal legislative districts get redrawn every 10 years, informed by the results of the decennial United States Census. The process is called redistricting. As I noted in the lesson, one change in 2022 to the borders for Tennessee’s state-level House of Representatives districts split MTSU’s campus in two.
Some saw the change as evidence of cracking, a type of gerrymander that aims to dilute a voting bloc’s political power by dividing the bloc into two or more groups and putting each group into a separate voting district that is dominated by otherwise-minded voters. The other main gerrymandering tactic, packing, involves grouping like-minded voters into as few districts as possible, removing their influence from surrounding voting districts.
Many observers charged Tennessee Republicans with orchestrating a cracking-style racial gerrymander during the 2022 redrawing of the districts for Tennessee’s nine seats in the U.S. House of Representatives.
Before the 2022 redistricting, Tennessee’s Fifth Congressional District, represented by Democratic Rep. Jim Cooper, generally followed the borders of Davidson County and the two counties immediately west of Davidson: Cheatham County (home to the cities of Ashland City and Kingston Springs) and Dickson County (home to the city of Dickson).
Below is a map of the districts as they were in 2021, with each district shaded according to the percentage of its residents who identified as white in the 2021 one-year American Community Survey. District 5 is the teal-colored district toward the center of the map. If you zoom in on the map, county borders show up as small dashed lines. Clicking on a district will show the name of the district, its estimated proportion of white voters, and the estimate’s error margin. Below the map is an error bar chart showing the white percentages for each district’s population, again according to the 2021 one-year American Community Survey:
The 2022 redistricting altered the map substantially. Most notably, it took away the ability of Davidson County residents to all vote for the same U.S. House representative. Instead, the redistricting split Davidson County across three U.S. House districts.
The Southern part of the Davidson County remained in District 5, but District 5 expanded to include parts of Williamson, Maury, and Wilson counties. Meanwhile, the northern part of Davidson County landed in District 7, which stretches into West Tennessee, and the Eastern part of Davidson County went into District 6, which runs as far east as Scott County.
The NAACP, the League of Women Voters and others filed a federal lawsuit alleging that the redistricting discriminated against minority voters. The lawsuit failed, however, after a three-judge panel ruled that the redistricting was likely motivated by partisanship rather than by racism. Gerrymandering to disenfranchise minority voters violates federal law. Under a recent U.S. Supreme Court decision, however, gerrymandering to gain a political advantage does not.
The panel invited the group to refile the case if the group could “plausibly disentangle race from politics,” but the group declined to do so, citing what the group called “new, substantial and unjust standards to prove racial gerrymandering.”
Below is a map of the districts as they were redrawn in 2022, with the districts shaded according to their white population percentages according to the 2022 one-year American Community Survey. Below the map is an error bar chart showing the estimates, again from the 2022 one-year ACS.
As you may recall from the Week 13 Lab Exercise, Davidson County tends to vote for Democratic candidates, especially in the heavily minority precincts in the central and southeastern areas of the county. The map you made for that lab exercise might be informative for this assignment. You are not required to reproduce it here, though.
The figure below plots each Davidson County precinct by both its percentage of nonwhite voters and its percentage of voters who backed Democratic presidential candidate Kamala Harris in the 2024 general election. The percentages voting for Harris come from the Tennessee Secretary of State’s official precinct-level results. The percent minority figures come from 2020 Census tract-level estimates that I applied to Davidson County’s precinct map using the geomander package for R. Using geomander is beyond the scope of this course, but you are free to investigate the package on your own.
In the figure, green dots represent precincts that Harris won. Orange dots represent precincts that her rival, Republican Donald Trump, won:
You will have all of class on Monday and Wednesday to work in-class on your final. The classroom also will be available to you during the scheduled two-hour final exam period on Friday from 10 a.m. to noon. I will be present for all three sessions. Your attendance is not required, though. Come if you need to. Work on your own outside of class if you prefer.
You may use notes, consult class materials on D2L, collaborate with one another, get AI help, Google stuff, etc.
You may ask me for help, but I’ll generally just refer you to the class materials you have worked through during the course. Code for everything you need to do is available in those materials or provided below. Some adaptation may be needed, but not much. I need you to show me what you can do based on your own resources, not what you can do with me walking you through the steps.
I’m generally a softie. But if you hit a road block, I’m not going to bail you out if I think it’s something you ought to know how to do by now, or at least ought to be able to figure out.
If I were you, I’d approach the assignment by following these steps:
You will need the name of an American Commnity Survey variable
that estimates each House district’s percentage of residents who are
write. If you need a refresher on how to look up an ACS variable name,
see Week 9’s “Monday: Using the Census API, Part 1” lesson. The code
there shows you how to look up variable names for the 2023 five-year
ACS. You’ll be working with data from 2021 and 2022 in this assignment,
but the lesson’s code will still work. Happily, the name of the variable
you are looking is the same across all three years. Census variables
about race can get a little perplexing, because race, itself, is a
perplexing concept. Plan on looking for the variable with the label:
Percent!!RACE!!Total population!!One race!!White
. Find the
variable name, and copy and paste it somewhere handy. You’ll need to
plug it into your code momentarily.
Open a blank R script file. In case you haven’t figured this out already: It’s a whole lot better to develop your code in an R script file and get it working flawlessly before you try to copy and paste it into a code block in an R Markdown document. If code goes haywire as you are knitting an R Markdown document, the error messages you get are even harder to figure out than the error messages you get when running faulty code in an ordinary R script window. Coding in R Markdown can seem like a shortcut. It isn’t.
Copy and paste in the code from Week 10’s “Monday: Using the
Census API, Part 3.” This lesson was about getting ACS data for a
variety of different types of geographic areas. The lesson noted that
tidycensus gives you access to about a dozen such area types, all of
which are listed on the Basic usage of tidycensus page under the
Geography in tidycensus heading. For this assignment,
you’ll be looking at U.S. House of Representatives districts for
Tennessee. We didn’t cover exactly how to get that geography - or
exactly how to get single-year rather than five-year data. So, I’ll give
you the code. Note, particularly, how the geography
,
state
, year
and survey
arguments
are worded:
# Fetching the data
mydata <- get_acs(
geography = "congressional district",
state = c("TN"),
variables = VariableList,
year = 2021,
survey = "acs1",
output = "wide",
geometry = TRUE)
A couple of additional mods to the code will save you some
headache later on. First, change the code template’s generic
Map
object name to something like Map2021
, and
the code’s generic mygraph
object name to something like
mygraph2021
. Later, when you go to put this code into your
RMarkdown document, having unique names for the 2021 map and graphic
will make it easier to display them exactly where you want them. This
also would be a good time to customize the title over the map’s legend
and the chart’s X axis label to match those shown in the
examples.
Running the code from the lesson - with the above modifications - should get you the 2021 map and the 2021 error bar chart. Both should match the examples perfectly.
Duplicate the code you just ran, but modify the
get_acs()
function’s year
argument to fetch
the 2022 data instead of the 2021 data. Also change the map and graphic
object names to something like Map2022
and
mygraph2022
so you can differentiate them from the 2021 map
and graphic later, when you’re setting everything up in R Markdown.
Remember to customize the map and graphic labels, too.
Run the 2022 code, and you should get the 2022 map and 2022 graphic. Again, they should match the examples.
That will leave you with making the plot that shows each precinct’s minority resident percentage and percentage of votes cast for Harris during the 2024 presidential election. Running this code will download the data file and open it as a data frame called Davidson2024:
Davidson2024 <- read.csv("https://github.com/drkblake/Data/raw/refs/heads/main/Davidson2024.csv")
The data frame’s Pct_Nonwhite
column contains the
percentage of minority voters in each precinct. The
Pct_Harris
column contains the percentage of precinct votes
cast for Harris. The Winner
column shows who won the
precinct: Harris, or Trump. Those are the three variables you
willneed.For help with making the figure, review the Week 12 lesson on
Data Visualization in R. That’s the lesson you worked through on your
own while I was in Las Vegas.
Once all of the above is working, open an R Markdown document, set it up as usual, and begin organizing your content. Start with a suitable headline of some kind. Then write up your interpretation of what the maps and graphics indicate about whether the 2022 redistricting amounted to a racial gerrymandering. Be sure to reference the maps and graphics as part of your analysis. Again, the degree or direction of the conclusion you reach about whether racial gerrymandering occurred will have no impact on your grade whatsoever. Three federal judges and the groups who filed suit over the redistricting couldn’t agree. I doubt everyone in the class will agree, either. What matters, here, is evidence that you can use the maps and graphics to inform your conclusion.
Paste your entire script into an R Markdown code chunk box, and configure the chunk to run the R code in the background but display no output.
Use an additional R Markdown code chunk box to display each of
the maps and graphics. One tip: If any R-generated messages show up
despite your having used the {r, echo=FALSE}
code chunk
option, try adding adding a message=FALSE
option, like
this: {r, echo=FALSE, message=FALSE}
. I found that the
additional option was needed when displaying the last plot - the one
showing each precinct’s percentage of minorities and percentage of votes
for Harris. Without it, the chunk displayed not only the plot but a
message about the code’s geom_smooth()
function.
Add a “Code:” headline.
Add a final R Markdown code chunk box, set the chunk options to {r, eval=FALSE}, and paste your R script into the box.
Knit the document, double check everything, publish your document to RPubs.com, and submit the document’s URL using the Final Exam URL Dropbox link in the Week 15 area of the course D2L site. Your submission is due by midnight on Friday.