Introduction

This project explores health differences across U.S. counties using data from the County Health Rankings, provided by the University of Wisconsin Population Health Institute.

I focused on four key health indicators:

These factors help us understand how healthcare access and lifestyle choices affect health across the country.

Source: https://uwphi.pophealth.wisc.edu/

Load Packages

library(tidyverse)
library(readr)

Load the Dataset

health_data <- read_csv(
  "analytic_data2025_v2 (1).csv",
  col_select = c(
    "Life Expectancy raw value",
    "Adult Obesity raw value",
    "Adult Smoking raw value",
    "Uninsured Adults raw value"
  )
)

Clean the Data

health_clean <- health_data %>%
  rename(
    life_expectancy = `Life Expectancy raw value`,
    adult_obesity = `Adult Obesity raw value`,
    adult_smoking = `Adult Smoking raw value`,
    uninsured_adults = `Uninsured Adults raw value`
  ) %>%
  mutate(across(everything(), as.numeric)) %>%
  drop_na()

Bar Graph: Average Life Expectancy by Obesity Group

# Create obesity groups
health_clean <- health_clean %>%
  mutate(obesity_group = case_when(
    adult_obesity < 0.3 ~ "<30%",
    adult_obesity < 0.35 ~ "30-35%",
    adult_obesity < 0.4 ~ "35-40%",
    TRUE ~ "40%+"
  ))

# Define custom colors
bar_colors <- c("<30%" = "#FFA500", "30-35%" = "#56B1F7", "35-40%" = "#800080", "40%+" = "gold")

# Bar graph
health_clean %>%
  group_by(obesity_group) %>%
  summarise(avg_life_expectancy = mean(life_expectancy)) %>%
  ggplot(aes(x = obesity_group, y = avg_life_expectancy, fill = obesity_group)) +
  geom_col() +
  scale_fill_manual(values = bar_colors) +
  labs(
    title = "Average Life Expectancy by Obesity Group",
    x = "Adult Obesity Rate Group",
    y = "Average Life Expectancy (Years)",
    caption = "Source: County Health Rankings"
  ) +
  theme_minimal(base_size = 13) +
  theme(legend.position = "none")

Scatterplot: Obesity vs Life Expectancy

ggplot(health_clean, aes(x = adult_obesity, y = life_expectancy)) +
  geom_point(aes(color = uninsured_adults), size = 3, alpha = 0.8) +
  scale_color_gradient(low = "yellow", high = "red") +
  labs(
    title = "Life Expectancy vs. Adult Obesity Rate",
    x = "Adult Obesity Rate (%)",
    y = "Life Expectancy (Years)",
    color = "% Uninsured",
    caption = "Source: County Health Rankings"
  ) +
  theme_minimal(base_size = 13)

Reflection

To prepare this dataset, I selected four key health variables and removed rows with missing values. I renamed the columns for clarity and converted them to numeric format.

The bar graph shows that counties with lower obesity rates tend to have higher average life expectancy. The scatterplot reinforces this pattern, showing a general downward trend in life expectancy as obesity rates increase.

If I had more time, I would explore geographic patterns or compare states and regions.