Overview: The article I chose is “Congress Today Than It’s Ever Been”. I choose this article because it ccaught my interest. I’ve been talking about this lately outside school; that many people in the office are just becoming older and older. And these older representative lack modern familiriaty with modern technology as the article stated. In this R I will show the trend in median age over time of representatives using graphs, and or plots. Link: https://fivethirtyeight.com/features/aging-congress-boomers/.

Plot Attempt

ggplot(data = congressage, aes(x = congress, y = age_years)) +
  geom_jitter(width = 0.1, height = 0, size = 2, alpha = 0.6, color = "darkblue") +
  xlab("Congress") +
  ylab("Age") +
  geom_line()

Sorted Group and Plotting

# Group by congress and calculated mean and median age      
  sortedCongress <- congressage %>%
  group_by(congress) %>%
  summarize(avg_age = mean(age_years, na.rm = TRUE),
            median_age = median(age_years, na.rm = TRUE))
  
# Plotting
  ggplot(sortedCongress, aes(x = congress)) +
  geom_point(aes(y = avg_age, color = "Average Age")) +
  geom_point(aes(y = median_age, color = "Median Age")) +
  xlab("Congress") +
  ylab("Age") +
  scale_color_manual(values = c("red", "blue"), guide = guide_legend(title = NULL)) +
  theme_minimal()

Line Graph for average and median age

# Create a line graph for average and median age
ggplot(sortedCongress, aes(x = congress)) +
  geom_line(aes(y = avg_age, color = "Average Age")) +
  geom_line(aes(y = median_age, color = "Median Age")) +
  xlab("Congress") +
  ylab("Age") +
  scale_color_manual(values = c("red", "blue"), guide = guide_legend(title = NULL)) +
  theme_minimal()

Summary of Sorted Congress

# Display the summary of sortedCongress
glimpse(sortedCongress)
## Rows: 53
## Columns: 3
## $ congress   <int> 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,…
## $ avg_age    <dbl> 51.73002, 52.60360, 52.56625, 53.22577, 53.95525, 54.61430,…
## $ median_age <dbl> 51.02533, 51.76044, 52.22450, 53.25530, 54.29158, 54.99521,…

Conclusion: Based on the plots, as congress became more and more(and th years increas) so did the age of representatives in Congress rise.