Rutherford County districts, by GRAPI percentage

if (!require("tidyverse")) install.packages("tidyverse") 
## Loading required package: tidyverse
## Warning: package 'tidyverse' was built under R version 4.3.2
## Warning: package 'ggplot2' was built under R version 4.3.2
## Warning: package 'tibble' was built under R version 4.3.2
## Warning: package 'tidyr' was built under R version 4.3.2
## Warning: package 'readr' was built under R version 4.3.2
## Warning: package 'purrr' was built under R version 4.3.2
## Warning: package 'dplyr' was built under R version 4.3.2
## Warning: package 'stringr' was built under R version 4.3.2
## Warning: package 'forcats' was built under R version 4.3.2
## Warning: package 'lubridate' was built under R version 4.3.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ purrr     1.0.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
if (!require("tidycensus")) install.packages("tidycensus")
## Loading required package: tidycensus
## Warning: package 'tidycensus' was built under R version 4.3.2
library(tidyverse) 
library(tidycensus)

census_api_key(
  "71f42f990c13d3e5c61a6c6f723de11b70e679a0", 
  install = TRUE, overwrite = TRUE)
## Your original .Renviron will be backed up and stored in your R HOME directory if needed.
## Your API key has been stored in your .Renviron and can be accessed by Sys.getenv("CENSUS_API_KEY"). 
## To use now, restart R or run `readRenviron("~/.Renviron")`
## [1] "71f42f990c13d3e5c61a6c6f723de11b70e679a0"
DetailedTables <- load_variables(2022, "acs5", cache = TRUE)
SubjectTables <- load_variables(2022, "acs5/subject", cache = TRUE)
ProfileTables <- load_variables(2022, "acs5/profile", cache = TRUE)

mydata <- get_acs(
  geography = "county subdivision",
  state = "TN",
  variables = c(MyVar_ = "DP04_0142P"),
  year = 2022,
  survey = "acs5",
  output = "wide")
## Getting data from the 2018-2022 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2018-2022 5-year ACS
## Using the ACS Data Profile

mydata <-
  separate_wider_delim(mydata,
                       NAME,
                       delim = ", ",
                       names = c("District", "County", "State"))

mydata <- filter(mydata, County == "Rutherford County")

mydata <- arrange(mydata, desc(MyVar_E))

head(mydata, 10)
## # A tibble: 10 × 6
##    GEOID      District    County            State     MyVar_E MyVar_M
##    <chr>      <chr>       <chr>             <chr>       <dbl>   <dbl>
##  1 4714990530 District 3  Rutherford County Tennessee    54      15.2
##  2 4714993190 District 17 Rutherford County Tennessee    49.2     8  
##  3 4714993570 District 19 Rutherford County Tennessee    48.3    15.9
##  4 4714993760 District 20 Rutherford County Tennessee    48.3    13.4
##  5 4714990720 District 4  Rutherford County Tennessee    47.3    15.2
##  6 4714991670 District 9  Rutherford County Tennessee    46.9    25  
##  7 4714991290 District 7  Rutherford County Tennessee    45.9    10.7
##  8 4714990910 District 5  Rutherford County Tennessee    41.5    10.5
##  9 4714991860 District 10 Rutherford County Tennessee    40.9    16.9
## 10 4714991480 District 8  Rutherford County Tennessee    36.6    18.5