Our dataset (LINK OF THE DATASET - https://www.kaggle.com/datasets/vellis1/us-cities-urban-connectivity) includes various data related to transportation and public services for cities in the United States that have a bigger population than 200 thousand people.
The above graph shows the difference between access to parks BIPOC people, and White people. The accessibility scores are only calculated for cities with over 200,000 people, and the mean is taken for each state. So, some states may not have sufficient data.
## The following wrangling is for calculating the inequality score (by adding the differences between all the population groups)
WithAccessibilityScore <- urban_connectivity %>%
mutate(InequalityScore = (Walkable_Park_Access_all_residents - Walkable_Park_Access_all_people_of_color) + (Walkable_Park_Access_high__125_city_median_income_ - Walkable_Park_Access_low__75_city_income_) + ( Walkable_Park_Access_seniors__65_ - Walkable_Park_Access_adults__19_64_)) %>%
select(Place_name, City, `State Short`, InequalityScore)
ForPlotP1 <- WithAccessibilityScore %>% ## Grouping state-wise, and calculating the mean
group_by(`State Short`) %>%
summarise(AvgInequalityScore = mean(InequalityScore))
ForPlotP1
## # A tibble: 34 × 2
## `State Short` AvgInequalityScore
## <chr> <dbl>
## 1 AK -0.106
## 2 AZ -0.0983
## 3 CA -0.0352
## 4 CO -0.0490
## 5 DC 0.00690
## 6 FL -0.00838
## 7 GA 0.0459
## 8 HI -0.0336
## 9 IA NA
## 10 ID -0.0419
## # ℹ 24 more rows
## The following wrangling groups all the race-wise 'Walkable Park Access Score', and groups them together state-wise (calculating the mean)
ForPlotP <- urban_connectivity %>%
group_by(`State Short`) %>%
summarise(AvgAccessAll = mean(Walkable_Park_Access_all_residents), AvgAcessBlack = mean(Walkable_Park_Access_black), AvgAcessHispanic = mean(Walkable_Park_Access_hispanic_latinx), AvgAcessAsian = mean(Walkable_Park_Access_asian), AvgAcessOthers = mean(Walkable_Park_Access_other_race), AvgAcessMultiple = mean(Walkable_Park_Access_multiple_races), AvgAcessPacific = mean(Walkable_Park_Access_pacific_islander),AvgAcessAmericanIndian = mean(Walkable_Park_Access_american_indian_alaska_native), AvgAcessWhite = mean(Walkable_Park_Access_white))
ForPlotP
## # A tibble: 34 × 10
## `State Short` AvgAccessAll AvgAcessBlack AvgAcessHispanic AvgAcessAsian
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 AK 0.756 0.791 0.748 0.823
## 2 AZ 0.572 0.575 0.619 0.544
## 3 CA 0.750 0.763 0.753 0.751
## 4 CO 0.860 0.857 0.874 0.842
## 5 DC 0.988 0.984 0.991 0.994
## 6 FL 0.668 0.705 0.642 0.563
## 7 GA 0.774 0.732 0.773 0.770
## 8 HI 0.724 0.519 0.648 0.789
## 9 IA NA NA NA NA
## 10 ID 0.701 0.687 0.653 0.696
## # ℹ 24 more rows
## # ℹ 5 more variables: AvgAcessOthers <dbl>, AvgAcessMultiple <dbl>,
## # AvgAcessPacific <dbl>, AvgAcessAmericanIndian <dbl>, AvgAcessWhite <dbl>
## The inequality score calculated before is presented spatially with the US Map
pIS <- plot_usmap(data = inequalityscores,
values = "AvgInequalityScore",
labels = TRUE) + ggtitle('Visualizing Inequality by States', subtitle = "Shows the difference between access for various groups based Income, Race, and Age") + scale_fill_continuous(low = "red", high = "white")
pIS + theme_grey(base_size = 10,
base_family = "Georgia")
avgaccess
## # A tibble: 34 × 12
## ...1 `State Short` AvgAccessAll AvgAcessBlack AvgAcessHispanic AvgAcessAsian
## <dbl> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 1 AK 0.756 0.791 0.748 0.823
## 2 2 AZ 0.572 0.575 0.619 0.544
## 3 3 CA 0.750 0.763 0.753 0.751
## 4 4 CO 0.860 0.857 0.874 0.842
## 5 5 DC 0.988 0.984 0.991 0.994
## 6 6 FL 0.668 0.705 0.642 0.563
## 7 7 GA 0.774 0.732 0.773 0.770
## 8 8 HI 0.724 0.519 0.648 0.789
## 9 9 IA NA NA NA NA
## 10 10 ID 0.701 0.687 0.653 0.696
## # ℹ 24 more rows
## # ℹ 6 more variables: AvgAcessOthers <dbl>, AvgAcessMultiple <dbl>,
## # AvgAcessPacific <dbl>, AvgAcessAmericanIndian <dbl>, AvgAcessWhite <dbl>,
## # fips <dbl>
library(classInt)
breaks <- c(0.3,0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1)
colors <- c("darkred","red","pink", "lightgreen", "green", "darkgreen")
labels <- c ("0.4-0.5","0.5-0.6", "0.6-0.7", "0.7 - 0.8", "0.8-0.9", "0.9-1")
avgaccess$AccessCategory <- cut(avgaccess$AvgAcessWhite, breaks = breaks, labels = FALSE, include.lowest = TRUE)
avgaccess$AccessCategory <- factor(avgaccess$AccessCategory)
pAll <- plot_usmap(data = avgaccess,
values = "AvgAccessAll",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States', subtitle = "Shows the Average Access to Park, irrespective of race") + scale_fill_gradient(low = "red", high = "green")
pAll + theme_linedraw(base_size = 10,
base_family = "Georgia")
pBlack <- plot_usmap(data = avgaccess,
values = "AvgAcessBlack",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States for People WIA Black', subtitle = "Shows the Average Access to Park, for people who identify as Black") + scale_fill_gradient(low = "red", high = "green")
pBlack + theme_linedraw(base_size = 10,
base_family = "Georgia")
pHispanic <- plot_usmap(data = avgaccess,
values = "AvgAcessHispanic",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States for people WIA Hispanic', subtitle = "Shows the Average Access to Park, for people who identify as Hispanic") + scale_fill_gradient(low = "red", high = "green")
pHispanic + theme_linedraw(base_size = 10,
base_family = "Georgia")
pAsian <- plot_usmap(data = avgaccess,
values = "AvgAcessAsian",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States for peoplw WIA Asian', subtitle = "Shows the Average Access to Park, for people who identify as Asian") + scale_fill_gradient(low = "red", high = "green")
pAsian + theme_linedraw(base_size = 10,
base_family = "Georgia")
pAI <- plot_usmap(data = avgaccess,
values = "AvgAcessAmericanIndian",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States for Indingenous People', subtitle = "Shows the Average Access to Park, for people who are Indigenous") + scale_fill_gradient(low = "red", high = "green")
pAI + theme_linedraw(base_size = 10,
base_family = "Georgia")
pWhite <- plot_usmap(data = avgaccess,
values = "AccessCategory",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States for people WIA White', subtitle = "Shows the Average Access to Park, for people who identify as Pacific Islander") + scale_fill_manual(values = colors)
pWhite + theme_linedraw(base_size = 10,
base_family = "Georgia")
## The following code converts the continuous variable to discrete variables
breaks <- c(0.3,0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1) ## Defining the breaks for the categories
colors <- c("darkred","red","pink", "lightgreen", "green", "darkgreen") ## List of colors for visualizing the categories
## The following code uses the 'cut' function to convert the columns to categories of breaks (listed above), and converts them to a factor
avgaccess$AccessWhiteCategory <- cut(avgaccess$AvgAcessWhite, breaks = breaks, labels = FALSE, include.lowest = TRUE)
avgaccess$AccessWhiteCategory <- factor(avgaccess$AccessWhiteCategory)
avgaccess$AccessAllCategory <- cut(avgaccess$AvgAccessAll, breaks = breaks, labels = FALSE, include.lowest = TRUE)
avgaccess$AccessAllCategory <- factor(avgaccess$AccessAllCategory)
avgaccess$AccessBlackCategory <- cut(avgaccess$AvgAcessBlack, breaks = breaks, labels = FALSE, include.lowest = TRUE)
avgaccess$AccessBlackCategory <- factor(avgaccess$AccessBlackCategory)
avgaccess$AccessHispanicCategory <- cut(avgaccess$AvgAcessHispanic, breaks = breaks, labels = FALSE, include.lowest = TRUE)
avgaccess$AccessHispanicCategory <- factor(avgaccess$AccessHispanicCategory)
avgaccess$AccessAsianCategory <- cut(avgaccess$AvgAcessAsian, breaks = breaks, labels = FALSE, include.lowest = TRUE)
avgaccess$AccessAsianCategory <- factor(avgaccess$AccessAsianCategory)
avgaccess$AccessAmericanIndianCategory <- cut(avgaccess$AvgAcessAmericanIndian, breaks = breaks, labels = FALSE, include.lowest = TRUE)
avgaccess$AccessAmericanIndianCategory <- factor(avgaccess$AccessAmericanIndianCategory)
## The following code uses the US Map package to visualize the data spatially on the US map (state-wise)
pAll <- plot_usmap(data = avgaccess,
values = "AccessAllCategory",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States', subtitle = "Shows the Average Access to Park, irrespective of race")+ scale_fill_manual(values = colors, labels.default(colors))
pAll + theme_linedraw(base_size = 10,
base_family = "Georgia")
pBlack <- plot_usmap(data = avgaccess,
values = "AccessBlackCategory",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States for People WIA Black', subtitle = "Shows the Average Access to Park, for people who identify as Black") + scale_fill_manual(values = colors, labels.default(colors))
pBlack + theme_linedraw(base_size = 10,
base_family = "Georgia")
pHispanic <- plot_usmap(data = avgaccess,
values = "AccessHispanicCategory",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States for people WIA Hispanic', subtitle = "Shows the Average Access to Park, for people who identify as Hispanic") + scale_fill_manual(values = colors, labels.default(colors))
pHispanic + theme_linedraw(base_size = 10,
base_family = "Georgia")
pAsian <- plot_usmap(data = avgaccess,
values = "AccessAsianCategory",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States for peoplw WIA Asian', subtitle = "Shows the Average Access to Park, for people who identify as Asian") + scale_fill_manual(values = colors, labels.default(colors))
pAsian + theme_linedraw(base_size = 10,
base_family = "Georgia")
pAI <- plot_usmap(data = avgaccess,
values = "AccessAmericanIndianCategory",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States for Indingenous People', subtitle = "Shows the Average Access to Park, for people who are Indigenous") +scale_fill_manual(values = colors, labels.default(colors))
pAI + theme_linedraw(base_size = 10,
base_family = "Georgia")
pWhite <- plot_usmap(data = avgaccess,
values = "AccessWhiteCategory",
labels = TRUE) + ggtitle('Visualizing Access to Park Access by States for people WIA White', subtitle = "Shows the Average Access to Park, for people who identify as Pacific Islander") + scale_fill_manual(values = colors, labels.default(colors))
pWhite + theme_linedraw(base_size = 10,
base_family = "Georgia")
exclude = c(“MT”, “WY”, “UT”, “ND”, “SD”, “IA”, “AR”, “MS”, “AL”, “TN”, “KY”, “IN”, “WV”, “NC”, “SC”, “ME”, “NI”, “VT”, “NH”, “DE”, “DC”, “RI”, “CT”),