-
Notifications
You must be signed in to change notification settings - Fork 121
/
global.R
45 lines (31 loc) · 965 Bytes
/
global.R
1
2
3
4
5
6
7
8
9
10
11
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
43
44
# load libraries
#library(rvest) required for initial scrape
library(leaflet)
library(dplyr)
#library(ggmap) required for obtaining lat lons
library(readr)
library(rgdal)
library(stringr)
library(tidyr)
library(rcstatebin)
library(shiny)
library(shinydashboard)
library(htmlwidgets)
library(DT)
# load requisite files
## earlier manipulation of "http://fortune.com/fortune500/"
fortune <- read.csv("fortune500.csv")
# create a rank
fortune <-fortune %>%
mutate(rank=row_number(),revRank=1001-rank)
## map spatial polygon from previously downloaded info
maps <- readOGR(dsn=".",
layer = "ne_50m_admin_1_states_provinces_lakes",
encoding = "UTF-8",verbose=FALSE)
#limit to US states and DC
states <-maps[50:100,]
# create a stateID fore merging
states$stateId <-str_replace(states$iso_3166_2,"US-","")
### Choropleth map
## take all states from rcstatebins data
allStates <- data.frame(state=unique(taxdata$state))