Introduction
I am using a data set of Congress member’s demographics to analyze a headline that reads “Congress Today Is Older Than It’s Ever Been” read from https://fivethirtyeight.com/features/aging-congress-boomers/. Is congress in general older? Is congress older when comparing party affiliations or state served in?
Packages
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.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── 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
library(dplyr)
Data
urlToRead <- "https://raw.githubusercontent.com/fivethirtyeight/data/refs/heads/master/congress-demographics/data_aging_congress.csv"
congressDemo <- read.csv(url(urlToRead))
str(congressDemo)
## 'data.frame': 29120 obs. of 13 variables:
## $ congress : int 82 80 81 82 83 84 85 86 87 88 ...
## $ start_date : chr "1951-01-03" "1947-01-03" "1949-01-03" "1951-01-03" ...
## $ chamber : chr "House" "House" "House" "House" ...
## $ state_abbrev : chr "ND" "VA" "VA" "VA" ...
## $ party_code : int 200 100 100 100 100 100 100 100 100 100 ...
## $ bioname : chr "AANDAHL, Fred George" "ABBITT, Watkins Moorman" "ABBITT, Watkins Moorman" "ABBITT, Watkins Moorman" ...
## $ bioguide_id : chr "A000001" "A000002" "A000002" "A000002" ...
## $ birthday : chr "1897-04-09" "1908-05-21" "1908-05-21" "1908-05-21" ...
## $ cmltv_cong : int 1 1 2 3 4 5 6 7 8 9 ...
## $ cmltv_chamber: int 1 1 2 3 4 5 6 7 8 9 ...
## $ age_days : int 19626 14106 14837 15567 16298 17028 17759 18489 19220 19950 ...
## $ age_years : num 53.7 38.6 40.6 42.6 44.6 ...
## $ generation : chr "Lost" "Greatest" "Greatest" "Greatest" ...
Creating a Subset
I created a subset of the congress demographics that I wish to analyze including the number of congress the member belongs to, the start date when the member started serving, the state which the member served, the party the member belonged to (100=Democrats, 200=Republicans, 328=Independents), the name of the member, the age in years of the member, and the generation to which the member belonged to (baby boomers, gen x, etc).
congressAges <- congressDemo |>
select('congress','start_date', 'state_abbrev', 'party_code', 'bioname', 'age_years', 'generation')
str(congressAges)
## 'data.frame': 29120 obs. of 7 variables:
## $ congress : int 82 80 81 82 83 84 85 86 87 88 ...
## $ start_date : chr "1951-01-03" "1947-01-03" "1949-01-03" "1951-01-03" ...
## $ state_abbrev: chr "ND" "VA" "VA" "VA" ...
## $ party_code : int 200 100 100 100 100 100 100 100 100 100 ...
## $ bioname : chr "AANDAHL, Fred George" "ABBITT, Watkins Moorman" "ABBITT, Watkins Moorman" "ABBITT, Watkins Moorman" ...
## $ age_years : num 53.7 38.6 40.6 42.6 44.6 ...
## $ generation : chr "Lost" "Greatest" "Greatest" "Greatest" ...
congressAges|>
group_by (party_code) |>
summarise(n())
Creating a new variable
I created a variable called party_name for better identification of the parties that congress members belong to rather than party_code.
congressAges <- congressAges |>
mutate(party_name = recode(party_code, '100' = 'Democratic', '200' = 'Republican', '328' = 'Idependent', '370' = 'Progressive', '537' = 'Farmer-Labor', '112' = 'Conservative', '329' = 'Independent Democrat', '331' = 'Independent Republican', '347' = 'Prohibitionist', '356' = 'Union Labor', '380' = 'Socialist', '402' = 'Liberal' ,'522' = 'American Labor', '523' = 'American Labor (La Quardia)'))
Averages by Congress
I grouped by congress number and averaged the age of congress members.
congressAges |>
group_by(congress) |>
summarise(mean_age = mean(age_years),n()) |>
arrange(desc(congress))
Conclusion
The average age of members in the 66th Congress was 52 years old comparing with the average age of the 118th congress to be 59 years. This does show that today congress is older than it was before.