Introduction

https://fivethirtyeight.com/features/aging-congress-boomers/

The median age of congress is at a record high and is trending to continue to increase. This is important to note as technology rapidly advances and there are concerns that congress members may be unable to keep up with modern technolgy.

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ 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
data <- read.csv("C:/Users/Lu/Documents/School/DATA607/Assignment1/congress-demographics/data_aging_congress.csv")
x <- data %>% 
  select(start_date, chamber, state_abbrev, birthday, age_days, age_years)
x <- x %>%
  group_by(year = year(start_date)) %>%
  summarize(median_age_years = median(age_years, na.rm = TRUE))
ggplot(data=x, aes(x = year, y = median_age_years)) +
  geom_line() +
  geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'

Conclusion

I grouped by year to find the median age in years and plotted the data to confirm visually and added a regression line to help show the trend.