Research Question

This study will attempt to measure whether increases in extractive industries (listed as “Mining, quarrying, and oil and gas extraction” in the ACS) in contributes to higher or lower levels of income inequality across combined statistical areas in the U.S.

Data: I’m trying to work within the knowledge I have and my interests keep going toward more aggregated data (probably becuase I’m so used to thinking of things as tracts or cities or counties). Therefore, I’m pulling aggregated 5 Year ACS data. Perhaps there are ways to tie this into more detailed analysis with disaggregated data. For the moment, I’m attempting to learn how to gather aggregate data in R. I am, admittedly, not yet sure how this will factor into a full regression analysis, especially with appropriate methods. But I’m starting somewhere and trying to learn along the way.

Timeframe: I’m pulling ACS Data for 2009-2013 and 2014-2018. Not only is 2018 the most recent year and 2013 the next non-overlapping year, but 2009-2013 generally a hot time for oil pries, where 2014-2018 followed a crash and saw a bit of a recover (West Texas Intermediate is the general baseline used for prices, and oil companies generally plan their “break even” at $60 a barrel).

Geography: I think examining changes at the Combined Statistical Area (CSA) level is the correct geography since CSAs are linked economic units. Counties could be used for a more detailed examination of the trends, but are less important geographies from a labor market standpoint.

Industry Definition: Due to limitations in the ACS data, this study will focus on all “extrative” industries: not only oil and gas, but also coal, mining, quarrying, and other mineral extraction. The increase of employment in these industries will be key to examine: areas with rapid employment increases or decreases could potentially be more at risk for shifting inequality.

Measuring inequality: I am still unsure of the best way to measure inequality by counties or by MSA. For the sake of this early analysis, I am choosing to focus on a simple measure for the time being: the income quintile share ratio. This is a ratio of the total income received by the top 20% of earners compared to the total income recieved by the bottom 20% of earners. These numbers are available from the ACS. This measure was used in a study examining the income inequality in areas of Russia that had seen increases in oil and gas employment (Bucellato & Mickiewicz, 2009).

I would be interested in calculating (or finding a source for?) more refined measures of income inequality at the CSA level. A study of similar scope (but spanning a longer timeframe) measured whether inequality has improved in Alaska after the creation of a “Permanent Fund Dividend” - where windfall profits from the oil industry are placed in a fund, and every year that fund is distributed equally to all full time Alaska residents (Kozminski and Baek, 2017). This study used three levels of inequality, but at the state level: the Gini Coefficient, Thiel’s Entropy Index, and the Relative Mean Deviation (RMD).
Other Variables: Since income is inextricably linked to other social factors in the U.S., and since the oil and gas industry is largely dominated by white men, incorporating race, ethnicity, and perhaps class of worker could be key to this analysis.

Load necessary packages.

options(repos="https://cran.rstudio.com" )
library(htmlTable)
library(car)
## Loading required package: carData
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
library(survey)
## Loading required package: grid
## Loading required package: Matrix
## Loading required package: survival
## 
## Attaching package: 'survey'
## The following object is masked from 'package:graphics':
## 
##     dotchart
library(questionr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:car':
## 
##     recode
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

#Prepping to pull from ACS

install.packages("tidycensus")
## 
##   There is a binary version available but the source version is later:
##            binary  source needs_compilation
## tidycensus  0.9.6 0.9.9.2             FALSE
## installing the source package 'tidycensus'
install.packages("tigris")
## 
## The downloaded binary packages are in
##  /var/folders/lr/thl33hwj2jdd01hth_whxlz00000gn/T//Rtmpvfe4mP/downloaded_packages
library(tidycensus)
library(sf)
## Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0
library(ggplot2)

#ATTEMPTED ACS PACKAGE WHICH PROMISED THINGS WOULD BE EASIER BUT COULDN'T GET IT TO WORK LEAVING HERE IN CASE I WANT TO REFERENCE IT LATER
#install.packages("acs", clean=T)
#library(acs)
#mygeo<-geo.make(state="TX")
#data_test<-acs.fetch(geography=mygeo, endyear=2018, variable = "B19082_001")
#View(data_test)

#census_api_key("76a8c99503b97d96cf9d7b170c23dd5a9070b289", install = TRUE)
# First time, reload your environment so you can use the key without restarting R.
#readRenviron("~/.Renviron")
# You can check it with:
Sys.getenv("CENSUS_API_KEY")
## [1] "76a8c99503b97d96cf9d7b170c23dd5a9070b289"
#Searching for ACS Variables
v18s <- load_variables(2018, "acs5/subject", cache = TRUE)

v18 <- load_variables(2018, "acs5", cache = TRUE)
#then can filter and view different variables

#Data Gathering As of now I am pulling data by county, but I am curious about how this would break down by MSA/CSA as well, so I might try to code each county into an MSA/CSA. For now though, I’m focusing only on counties.

These data will be pulled from 2009-2013 and 2014-2018 ACS by county Total workers in Mining, Quarrying, Oil + Gas (includes part time) = S2403_C01_004 Total workers 16 and older (includes part time) = S2403_C01_001 Share of aggregate income, lowest quintile = B19082_001 Share of aggregate income, highest quintile = B19082_005

Other measures I think would be interesting to include in the future: * Percent white population * Percent hispanic population * Population below poverty (would prefer to calculate own measure instead of using percent I can get from ACS directly, because that measure does not include children under 18)

#Pulling various acs variables for 2014-2018 and 2009-2013.
#Pulling Extractive Employment Data, and cleaning it up
ext18_CSA<-get_acs(geography="combined statistical area", year=2018,variables="S2403_C01_004")
## Getting data from the 2014-2018 5-year ACS
## Using the ACS Subject Tables
#I know the margin of error is important, I'm just removing it to make my life easier for now. 
ext18<-get_acs(geography="combined statistical area", year=2018, variables="S2403_C01_004")%>%
  rename(`ext18` = estimate) %>%
  select(-moe, -variable) 
## Getting data from the 2014-2018 5-year ACS
## Using the ACS Subject Tables
ext13<-get_acs(geography="combined statistical area", year=2013, variables="S2403_C01_004")%>%
  rename(`ext13` = estimate) %>%
  select(-moe, -variable) 
## Getting data from the 2009-2013 5-year ACS
## Using the ACS Subject Tables
totwrk18<-get_acs(geography="combined statistical area", year=2013, variables="S2403_C01_001")%>%
  rename(`totwrk18` = estimate) %>%
  select(-moe, -variable) 
## Getting data from the 2009-2013 5-year ACS
## Using the ACS Subject Tables
totwrk13<-get_acs(geography="combined statistical area", year=2013, variables="S2403_C01_001")%>%
  rename(`totwrk13` = estimate) %>%
  select(-moe, -variable) 
## Getting data from the 2009-2013 5-year ACS
## Using the ACS Subject Tables
LQ_inc18<-get_acs(geography="combined statistical area", year=2018, variables="B19082_001")%>%
  rename(`LQ_inc18` = estimate) %>%
  select(-moe, -variable) 
## Getting data from the 2014-2018 5-year ACS
LQ_inc13<-get_acs(geography="combined statistical area", year=2013, variables="B19082_001")%>%
  rename(`LQ_inc13` = estimate) %>%
  select(-moe, -variable) 
## Getting data from the 2009-2013 5-year ACS
HQ_inc18<-get_acs(geography="combined statistical area", year=2018, variables="B19082_005")%>%
  rename(`HQ_inc18` = estimate) %>%
  select(-moe, -variable) 
## Getting data from the 2014-2018 5-year ACS
HQ_inc13<-get_acs(geography="combined statistical area", year=2013, variables="B19082_005")%>%
  rename(`HQ_inc13` = estimate) %>%
  select(-moe, -variable) 
## Getting data from the 2009-2013 5-year ACS
#Combining data into one dataset (is there a better way to do this?? Maybe I'm just learning the hard way.)
csas <- merge(merge(merge(merge(merge(merge(merge(
  ext13,ext18,all=TRUE),
  totwrk13,all=TRUE),
  totwrk18,all=TRUE),
  LQ_inc13,all=TRUE),  
  LQ_inc18,all=TRUE),
  HQ_inc13,all=TRUE),
  HQ_inc18,all=TRUE)

#Data Calculations First, I need to calculate the share of Extractive industry employment in each MSA, and calculate the income quintile share ratio.

#Absolute Change 2013-2013 in Extractive Industry Employment
csas$Ch_Ext_1318<-csas$ext18-csas$ext13
#Percent Change 2013-2013 in Extractive Industry Employment
csas$PCh_Ext_1318<-(csas$ext18-csas$ext13)/csas$ext13
#Income Quintile Share for 2013
csas$IncQS_13<-(csas$HQ_inc13/csas$LQ_inc13)
#Income Quintile Share for 2018
csas$IncQS_18<-(csas$HQ_inc18/csas$LQ_inc18)

#Histogram of percent change shows some outliers, probably some really low or 0 values in 2013 that should be cleaned out.
hist(csas$PCh_Ext_1318)

#A surprising share of CSAs have really low IQS in 2013 and 2018. Maybe I need to recheck data.
hist(csas$IncQS_13)

hist(csas$IncQS_18)

#Tried to get a share of oil employment correlated with Income Inequality Measure - is this because some of my values are NA? Noting this so I remember to try to clean that out for future consideration. 
shareExt18 <- csas$ext18/csas$totwrk18
cor(csas$IncQS_18,shareExt18)
## [1] NA

#Maps To get a better understanding for what exactly we’re looking at, I want to make some maps.

However, I’m running into the following problems. Which I know I’ll probably learn in the GIS class eventually, but even being a decent ArcGIS user I’m having a hard time Googling the right terms to get my questions answered. So, they come to you: * I couldn’t get the below code to work to include a basic state boundary outline. What am I doing wrong? Or is my computer just not strong enough to handle it? * I want to better undertand the options for making choropleth breaks. What does the “p=seq(0,1,length.out = 6)” section of the code do? What are the other options beside quintile? Can you make manual breaks? * How do I set the extent and projected coordinate system of the map? On the one state map I got to work, Alaska was skewing things. I saw tidycensus has an option to place Alaska and Hawaii somewhere nearby for ease of use, but I can’t figure out if that integrates with the below. * P.S. Not a question, but I’m a longtime fan of color brewer’s colors and was really excited to see they can be integrated into R.

library(ggplot2)
library(ggthemes)
library(rgeos)
## Loading required package: sp
## rgeos version: 0.5-1, (SVN revision 614)
##  GEOS runtime version: 3.7.2-CAPI-1.11.2 
##  Linking to sp version: 1.3-1 
##  Polygon checking: TRUE
library(sp)
options(tigris_class="sf")

csa_18<-tigris::combined_statistical_areas(cb = T, year = 2018)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
csa_13<-tigris::combined_statistical_areas(cb = T, year = 2013)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================| 100%
usa<-tigris::states(cb=T)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================| 100%
BaseUS <-plot(usa)

csa_18_join<-tigris::geo_join(csa_18, csas, by_sp="GEOID", by_df="GEOID",how="left" )


csa_18_join%>%
  mutate(ch_ext_group = cut(Ch_Ext_1318, breaks=quantile(Ch_Ext_1318, p=seq(0,1,length.out = 6), na.rm=T ), include.lowest=T ))%>%
  ggplot()+
  geom_sf(aes(fill=ch_ext_group, color=NA))+
  scale_color_brewer(palette = "Blues")+
  scale_fill_brewer(palette = "Blues",na.value = "grey50")+
#  geom_sf(data=usa, color="black")
#  coord_sf(crs = 102008)+
  ggtitle(label = "Change in Extractive Industry Employment by CSA, 2013-2018")

csa_18_join%>%
  mutate(IncQS_18_group = cut(IncQS_18, breaks=quantile(IncQS_18, p=seq(0,1,length.out = 6), na.rm=T ), include.lowest=T ))%>%
  ggplot()+
  geom_sf(aes(fill=IncQS_18_group, color=NA))+
  scale_color_brewer(palette = "Blues")+
  scale_fill_brewer(palette = "Blues",na.value = "grey50")+
#  geom_sf(data=usa, color="black")
#  coord_sf(crs = 102008)+
  ggtitle(label = "Income Quintile Share Ratio by CSA, 2018")