Midwest Dataset Analysis
Graph 1: Population Below Poverty Line (Histogram)
ggplot(mw, aes(x = percbelowpoverty)) +
geom_histogram(binwidth = 5) +
labs(title = "Histogram of Population Below Poverty Line",
x = "Percent Below Poverty",
y = "Count")

Graph 2: Population Below Poverty Line (Density Plot)
ggplot(mw, aes(x = percbelowpoverty)) +
geom_density(fill = "skyblue") +
labs(title = "Density Plot of Population Below Poverty Line",
x = "Percent Below Poverty",
y = "Density")

Graph 3: Combined Histogram and Density Plot
ggplot(mw, aes(x = percbelowpoverty)) +
geom_histogram(aes(y = ..density..), binwidth = 5,
fill = "lightblue", color = "black") +
geom_density(color = "red", linewidth = 1,
fill = "pink", alpha = 0.3) +
labs(title = "Combined Histogram and Density Plot",
x = "Percent Below Poverty",
y = "Density")

Graph 4: Poverty Line by State (Density Plot)
ggplot(mw, aes(x = percbelowpoverty, fill = state)) +
geom_density(alpha = 0.3) +
labs(title = "Density Plot by State",
x = "Percent Below Poverty",
y = "Density")

Graph 5: Poverty Line for Indiana and Michigan
ggplot(mw %>% filter(state %in% c("IN", "MI")),
aes(x = percbelowpoverty, fill = state)) +
geom_density(alpha = 0.3) +
labs(title = "Density Plot for IN and MI",
x = "Percent Below Poverty",
y = "Density")

Graph 6: College Education by State (Density Plot)
ggplot(mw, aes(x = percollege, fill = state)) +
geom_density(alpha = 0.3) +
labs(title = "Density Plot of College Education by State",
x = "Percent with College Degree",
y = "Density")

Graph 7: College Education for Indiana and Michigan
ggplot(mw %>% filter(state %in% c("IN", "MI")),
aes(x = percollege, fill = state)) +
geom_density(alpha = 0.3) +
labs(title = "College Education Density Plot for IN and MI",
x = "Percent with College Degree",
y = "Density")

Graph 8: College Education by State (Box Plot)
ggplot(mw, aes(x = state, y = percollege, fill = state)) +
geom_boxplot() +
labs(title = "Box Plot of College Education by State",
x = "State",
y = "Percent with College Degree")

Graph 9: College Education (Violin and Box Plot)
ggplot(mw, aes(x = state, y = percollege, fill = state)) +
geom_violin() +
geom_boxplot(width = 0.2, fill = "white") +
labs(title = "Combined Violin and Box Plot of College Education",
x = "State",
y = "Percent with College Degree")

Graph 10: Professional Employment by State
mw %>%
group_by(state) %>%
summarize(mean_prof = mean(percprof)) %>%
ggplot(aes(x = state, y = mean_prof)) +
geom_bar(stat = "identity", fill = "steelblue") +
labs(title = "Mean Professional Employment by State",
x = "State",
y = "Mean Percent Professional Employment")

Graph 11: College Education vs Poverty
ggplot(mw, aes(x = percollege, y = percbelowpoverty)) +
geom_point() +
labs(title = "College Education vs Poverty",
x = "Percent with College Degree",
y = "Percent Below Poverty")

Graph 12: College Education vs Poverty with Trend
ggplot(mw, aes(x = percollege, y = percbelowpoverty)) +
geom_point() +
geom_smooth(method = "loess") +
labs(title = "College Education vs Poverty with Trend Line",
x = "Percent with College Degree",
y = "Percent Below Poverty")

Graph 13: Multi-Variable Analysis
ggplot(mw, aes(x = percollege, y = percbelowpoverty,
color = state, size = popdensity)) +
geom_point() +
labs(title = "College Education vs Poverty by State and Population Density",
x = "Percent with College Degree",
y = "Percent Below Poverty")

MPG Dataset Analysis
Graph 15: Highway Fuel Economy by Vehicle Class
ggplot(mpg_data, aes(x = class, y = hwy, fill = class)) +
geom_boxplot() +
labs(title = "Highway Fuel Economy by Vehicle Class",
x = "Vehicle Class",
y = "Highway MPG")

Graph 16: Highway Fuel Economy (2008 Models)
ggplot(mpg_data %>% filter(year == 2008),
aes(x = class, y = hwy, fill = class)) +
geom_boxplot() +
labs(title = "Highway Fuel Economy by Vehicle Class (2008)",
x = "Vehicle Class",
y = "Highway MPG")

Graph 17: City Fuel Economy by Year
ggplot(mpg_data, aes(x = cty, fill = factor(year))) +
geom_density(alpha = 0.3) +
labs(title = "City Fuel Economy by Year",
x = "City MPG",
y = "Density")

Graph 18: City vs Highway Fuel Economy (2008)
ggplot(mpg_data %>% filter(year == 2008),
aes(x = cty, y = hwy)) +
geom_point() +
geom_smooth(method = "loess") +
labs(title = "City vs Highway Fuel Economy (2008)",
x = "City MPG",
y = "Highway MPG")

Graph 19: Highway Fuel Economy by Drive Type (2008)
ggplot(mpg_data %>% filter(year == 2008),
aes(x = drv, y = hwy, fill = drv)) +
geom_boxplot() +
labs(title = "Highway Fuel Economy by Drive Type (2008)",
x = "Drive Type",
y = "Highway MPG")

Graph 20: Highway Fuel Economy (Violin and Box Plot)
ggplot(mpg_data %>% filter(year == 2008),
aes(x = drv, y = hwy, fill = drv)) +
geom_violin() +
geom_boxplot(width = 0.2, fill = "white") +
labs(title = "Highway Fuel Economy by Drive Type (2008)",
x = "Drive Type",
y = "Highway MPG")
