#load libraries 
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.6.1
## Warning: package 'ggplot2' was built under R version 4.6.1
## Warning: package 'tibble' was built under R version 4.6.1
## Warning: package 'tidyr' was built under R version 4.6.1
## Warning: package 'readr' was built under R version 4.6.1
## Warning: package 'purrr' was built under R version 4.6.1
## Warning: package 'dplyr' was built under R version 4.6.1
## Warning: package 'stringr' was built under R version 4.6.1
## Warning: package 'forcats' was built under R version 4.6.1
## Warning: package 'lubridate' was built under R version 4.6.1
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.3     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(gt)
## Warning: package 'gt' was built under R version 4.6.1
library(sf)
## Warning: package 'sf' was built under R version 4.6.1
## Linking to GEOS 3.14.1, GDAL 3.12.1, PROJ 9.7.1; sf_use_s2() is TRUE
library(e1071)
## Warning: package 'e1071' was built under R version 4.6.1
## 
## Attaching package: 'e1071'
## 
## The following object is masked from 'package:ggplot2':
## 
##     element
library(tmap)
## Warning: package 'tmap' was built under R version 4.6.1
## 
## Attaching package: 'tmap'
## 
## The following object is masked from 'package:gt':
## 
##     metro
#read in data
acs_tract_nc <- st_read("https://drive.google.com/uc?export=download&id=1xjkxq0KaIMAd8ag0e_m2B1O_he2CSyVR") |> filter(COUNTYFP %in% c("135", "183", "063"))
## Reading layer `nc_tract_acs_2023' from data source 
##   `https://drive.google.com/uc?export=download&id=1xjkxq0KaIMAd8ag0e_m2B1O_he2CSyVR' 
##   using driver `GeoJSON'
## Simple feature collection with 2672 features and 53 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -84.32182 ymin: 33.75288 xmax: -75.40012 ymax: 36.58814
## Geodetic CRS:  NAD83
## create a basic table of descriptive statistics
acs_tract_nc |> st_drop_geometry() |>
  select(pct_pov) |>
  summarise(
    n = n(),
    num_na = sum(is.na(pct_pov)),
    mean_pov = mean(pct_pov, na.rm = TRUE),
    median_pov = median(pct_pov, na.rm = TRUE),
    sd_pov = sd(pct_pov, na.rm = TRUE),
    mean_dev = mean(abs(pct_pov - mean(pct_pov, na.rm = TRUE)), na.rm = TRUE),
    min_pov = min(pct_pov, na.rm = TRUE),
    max_pov = max(pct_pov, na.rm = TRUE),
    skewness = skewness(pct_pov, na.rm = TRUE),
    kurtosis = kurtosis(pct_pov, na.rm = TRUE)
  ) |> pivot_longer(everything(), names_to = "Statistic", values_to = "Value") |>
  gt() |>
  tab_header(
    title = "Percent of Population Below Poverty Line, NC Census Tracts (ACS 2019–2023)"
 ) |>
  fmt_number(
    columns = everything(),
    decimals = 2
  )
Percent of Population Below Poverty Line, NC Census Tracts (ACS 2019–2023)
Statistic Value
n 340.00
num_na 0.00
mean_pov 10.27
median_pov 7.55
sd_pov 10.80
mean_dev 7.10
min_pov 0.00
max_pov 100.00
skewness 3.21
kurtosis 17.06
##Non-map visualization: histogram
ggplot(acs_tract_nc, aes(x = pct_pov)) +
  geom_histogram(binwidth = 2, fill = "lightgrey", color = "black", alpha = 0.7) +
  labs(
    title = "Histogram of Percent Population Below Poverty Line",
    x = "Percent Below Poverty (%)",
    y = "Number of Census Tracts"
  )

# 3. Map
tm_shape(acs_tract_nc) +
  tm_polygons(fill = "pct_pov", fill.scale = tm_scale_continuous(values = "viridis"))

  1. I learned that most of North Carolina has relatively low poverty rates with a bulk of tracts falling under around 20 with the most common range being around 0-.05 making the distribution strongly right-skewed.

  2. The map shows that poverty is not evenly distributed across the study area and is concentrated in a small number of specific tracts rather than spread broadly across the region. The higher-poverty tracts appear in isolated pockets and tend to fall within the areas with smaller, denser tract boundaries which corresponds with more urbanized neighborhoods.