aqi_state_graph =
aqi_year_df %>%
group_by(county) %>%
ggplot(aes(x = year, y = aqi_mean, color = county)) +
geom_point(alpha=.3) +
geom_line() +
labs(
title = "Air Quality Index by county in NY state, 2003-2012",
x = "Year",
y = "Air Quality Index"
)+
scale_x_continuous(breaks = 2003:2012 )+
scale_color_viridis(
name = "County",
discrete = TRUE
)
aqi_state_graph
New York
, Bronx
, Erie
and
Queens
. However, some counties are with lower air quality
index, as lower as 10-30, for example, Franklin
,
Columbia
,St. Lawrence
and
Kings
.aqi_county_graph =
aqi_year_df %>%
group_by(county) %>%
summarize(
aqi_all = mean(aqi_mean),
max = max(aqi_mean),
min = min(aqi_mean)
) %>%
mutate(county = fct_reorder(county, aqi_all)) %>%
ggplot(aes(x = county, y = aqi_all)) +
geom_point()+
geom_errorbar(mapping = aes(ymin = min, ymax = max)) +
labs( x = "County", y = "Air Quality Index", title = "Mean AQI for different counties in NY State, 2003-2012") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1))
aqi_county_graph
Bronx
,
New York
, Queens
, Erie
and
Richmond
) and top 5 counties with best air
quality(Columbia
, Franklin
,
St. Lawrence
, Schenectady
and
Dutchess
)air_county_df =
aqi_year_df %>%
group_by(state_code, county_code,county) %>%
summarize(
aqi_all = mean(aqi_mean),
max = max(aqi_mean),
min = min(aqi_mean)
) %>%
mutate(
fips = str_c(state_code,county_code)
)
county_plot_map =
plot_usmap(regions = "county", include = c("NY"), data = air_county_df, values = "aqi_all", labels = TRUE, label_color = "white") +
scale_fill_continuous(
low = "white", high = "Red", name = "Air Quality Index", label = scales::comma, limits = c(0,60)
) +
labs(
title = "AQI by counties in NY State on mapp"
)+
theme(legend.position = "right")
county_plot_map
air_quality_day_df =
air_daily_df %>%
group_by(state_code, county_code,county) %>%
mutate(
aqi_status = case_when(
category %in% c("Good", "Moderate") ~ "Healthy",
category %in% c("Unhealthy for Sensitive Groups", "Unhealthy", "Very Unhealthy") ~ "Unhealthy"
)
)
Unhealthy_air_graph =
air_quality_day_df %>%
filter(aqi_status == "Unhealthy") %>%
group_by(county) %>%
summarize(
unhealthy_days = n()
) %>%
mutate(
county = fct_reorder(county, unhealthy_days)
) %>%
ggplot(aes(y = county, x = unhealthy_days, fill = unhealthy_days)) +
geom_col() +
labs(
title = "Unhealthy air quality days by counties in NY State, 2003-2012",
x = "Unhealthy air quality days",
y = "County"
) +
scale_fill_viridis(option = "turbo")
Unhealthy_air_graph
Suffolk
, Chautauqua
, Richmond
,
Erie
and Westchester
.