In this data dive, we will be looking at the documentation for the data and how that affects our understanding of the data.
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.3 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
cdata <- read.csv("/Users/cadgo/Downloads/data_aging_congress.csv")
cdf <- data.frame(cdata)
head(cdf)
## congress start_date chamber state_abbrev party_code bioname
## 1 82 1951-01-03 House ND 200 AANDAHL, Fred George
## 2 80 1947-01-03 House VA 100 ABBITT, Watkins Moorman
## 3 81 1949-01-03 House VA 100 ABBITT, Watkins Moorman
## 4 82 1951-01-03 House VA 100 ABBITT, Watkins Moorman
## 5 83 1953-01-03 House VA 100 ABBITT, Watkins Moorman
## 6 84 1955-01-03 House VA 100 ABBITT, Watkins Moorman
## bioguide_id birthday cmltv_cong cmltv_chamber age_days age_years generation
## 1 A000001 1897-04-09 1 1 19626 53.73306 Lost
## 2 A000002 1908-05-21 1 1 14106 38.62012 Greatest
## 3 A000002 1908-05-21 2 2 14837 40.62149 Greatest
## 4 A000002 1908-05-21 3 3 15567 42.62012 Greatest
## 5 A000002 1908-05-21 4 4 16298 44.62149 Greatest
## 6 A000002 1908-05-21 5 5 17028 46.62012 Greatest
As you can see in the above data frame, we have multiple columns of data where it might be unclear on what it is trying to show. For me, these columns include bioguide_id, cmltv_cong, and cmltv_chamber.
After some digging on FiveThirtyEight’s website, I found out why they named these columns what they did and what they mean. The bioguide_id is just a unique identifier for each member of congress, and is included in case any of them share a name.
The cmltv_cong column just shows how many terms they had served in total in congress at the time they started in each congress session. For members who were in both chambers, this will be a larger number when they switch chambers than the cmltv_chamber column.
The cmltv_chamber column just shows how many terms thay have served in that specific chamber. This helps with determining how much time each member had spent in each chamber and can help with data analysis on reelection efforts for incumbents.
The column that I still struggle with after reading the documentation is the party_code column. There is no documentation available to give names to the party_code id that they are assigned. All of the party codes will be shown below.
party <- table(cdf$party_code)
knitr::kable(party, format = "html",)
| Var1 | Freq |
|---|---|
| 100 | 15804 |
| 112 | 3 |
| 200 | 13181 |
| 328 | 44 |
| 329 | 3 |
| 331 | 2 |
| 347 | 1 |
| 356 | 1 |
| 370 | 29 |
| 380 | 4 |
| 402 | 1 |
| 522 | 7 |
| 523 | 1 |
| 537 | 39 |
After doing some digging, I was able to solve that party code 100 is the Democrat party and party code 200 is the Republican party. Outside of that, I cannot solve which parties are assigned to the other party codes.
I’m not sure why they had the data displayed like this, unless they collected the data from a source where it assigned unique ids to each party and decided to keep it.
Here I will create a chart to display the frequency each party is shown in the data.
barplot(party, xlab ='Party Code', ylab = 'Frequency', main = 'Frequency of each Party', col = 'blue')
After creating the chart, it does not help explain what each party is, but it does show their insignificance to the data overall. Unless you wanted to a deep analysis on the average age of each party that is not republican or democrat, then it would be useful to find out which party code went to which party. But since I cannot find the documentation for that, I will ignore non-major party members when it comes to analyzing the difference between political parties.
There are no negative risks with not knowing the party names, so there are no negative consequences in leaving the data in for overall analysis.