cd_info_long | R Documentation |
cd_info_long
provides a "long" version of the yearly cd_info_20**
datasets.
cd_info_long
cd_info_long
is a dataframe with 13050 rows,
covering the maps of 9 election years
(2008, 2010, 2012, 2014, 2016, 2018, 2020, 2022, 2024) for each of the 435 congressional districts.
lines
Is the year corresponding to the geography (district line). For example, lines = 2008
and cd = "AL-01
indicates that the row is representing AL-01's geography as used in the 2008 election.
cd
Is the CD corresponding to the year of the geography (district line). Note that districts can change drastically
by redistricting; a state's "first congressional district" from one lines
can cover a different area
than the same first congressional district for another.
elec
Is the year of the election for the presidential election data that follows
party
, candidate
Define the presidential candidate that corresponds to the elec
(which may not be the same as lines
). For example, lines = 2012, cd = AL-01
combined with
elec = 2008
represents the 2008 election results in the newly redistricted (2012) AL-01 geography
pct
The two party voteshares of the candidate
presvotes_total
The total number of votes for President in that CD
presvotes_DR
The total number of Democrat + Republican votes for President in that CD
cd_info for versions with one row per district, and documentation of sources
library(dplyr)
# get only data for proximate years
cd_info_long |> filter((elec == lines) | (elec + 2 == lines))
# this subset returns exactly 2 * 435 districts per cycle:
cd_info_long |> filter((elec == lines) | (elec + 2 == lines)) |> count(lines, party)
# this will show where the districts lines changed between 2022 and 2024
# (same election, same candidate, different map)
cd_info_long |>
filter(lines %in% c(2022, 2024), elec == 2020, candidate == "biden") |>
arrange(cd, lines)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.