Dependencies and Initial Data Structure

GDP per Capita Data

Our data source for the GPD per capita for states is: https://apps.bea.gov/iTable/iTable.cfm?0=1200&isuri=1&reqid=70&step=10&1=1&2=200&3=sic&4=1&5=xx&6=-1&7=-1&8=-1&9=70&10=levels#reqid=70&step=10&isuri=1&7003=1000&7035=-1&7004=naics&7005=1&7006=xx&7036=-1&7001=11000&7002=1&7090=70&7007=-1&7093=levels

To directly access the file (through read.csv) you could isolate the redirect URL to pull the data down directly,

Instead, however, using the UI, downloaded the CSV data and selected the 2017 data from the underlying dataset.

This provided us with the download.csv found in the below code (which we trimmef for regions/Washington DC)

For the purpose of reproducibility we’ve included the raw data, and commented out the other process.

#gdp<-read.csv('download.csv',skip=4)
#gdptrim<-gdp[2:52,]
#gdptrim<-gdptrim[gdptrim$Area!='District of Columbia',]
#df$gdp_per<-gdptrim$X2017

df$gdp_per<-c(37508L, 63610L, 39583L, 36714L, 60359L, 54026L, 62633L, 63955L, 
39842L, 45925L, 52869L, 36441L, 55102L, 46427L, 52284L, 47435L, 
39277L, 44372L, 39521L, 56375L, 66500L, 44201L, 54805L, 32447L, 
43036L, 39833L, 54654L, 44812L, 52509L, 56776L, 41619L, 65220L, 
44706L, 64911L, 48188L, 44535L, 51312L, 51841L, 48314L, 37637L, 
48004L, 44348L, 53737L, 45493L, 44831L, 52124L, 59333L, 37353L, 
48666L, 61091L)

States Data & Mapping

Using the states dataset provided by default in R, we used the centers of the states to plot circles based on their GDP. The dataset did use center for Haawaii and Alaska that are much closer to the other states for simple visualizations.

df %>%
  leaflet() %>% 
  addTiles() %>% 
  addCircles( weight=3,radius=(df$gdp_per) )
## Assuming "lng" and "lat" are longitude and latitude, respectively

Follow Up

Next steps to take involve be adding in data for several other years, calculating a position slightly off the origin of the original, and then allowing for trend comparison for how the GDP per capita has changed (by tweaking the representative colors and including a key)