forked from david-wavrock/ije-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_testing2.R
119 lines (98 loc) · 3.67 KB
/
map_testing2.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
## map testing 2 with plotly
library(plotly)
library(tidyverse)
## data
mapfilter <- table_1_2 %>%
filter(year==2012,
source=="T1 Personal Master File",
gender == "Both",
type == "Incoming",
income_source == "Outside the Jurisdiction")
mapdat <- simple_pr_shapefile %>%
inner_join(mapfilter,by='PRUID') %>%
mutate(geometry=sf::st_transform(
simple_pr_shapefile$geometry,
crs= "+proj=laea +lat_0=56.1304 +lon_0=-86.3468 +ellps=WGS84 +units=m +no_defs "))
if(input$SeriesInput == "Employees"){
seriesvar <- mapdat$count
seriestitle <- 'Number of Inter-Jurisdictional Employees'
pal_count_PR <- createClasses(mapdat$count , "Blues", "transparent", 5)
geo_labels_PR <- sprintf(
"<strong>%s (Employees): %s </strong>",
mapdat$province, format(mapdat$count, big.mark = ",")) %>%
lapply(htmltools::HTML) # add labels
} else if(input$SeriesInput == "Income"){
seriesvar <- mapdat$income
seriestitle <- 'Income of Inter-Jurisdictional Employees'
pal_count_PR <- createClasses(mapdat$income, "Reds", "transparent", 5)
geo_labels_PR <- sprintf(
"<strong>%s (Income): %s </strong>",
mapdat$province, format(mapdat$income, big.mark = ",")) %>%
lapply(htmltools::HTML) # add labels
}
## continuous
ggplotly(
ggplot(mapdat) +
geom_sf(aes(fill=log(count)/log(10),
text=sprintf("<b>%s</b><br>Count: %s<br>Income: %s",
province,
format(count,big.mark=','),
paste0('$',format(round(income/1000000,1),big.mark=','),' M'))),
color="#444444",
alpha=0.75) + theme_bw() +
scale_fill_gradient(low='#f1eef6',
high='#045a8d',
na.value='grey.50') +
theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank(),
axis.title.x=element_blank(),axis.text.x=element_blank(),axis.ticks.x=element_blank(),
axis.title.y=element_blank(),axis.text.y=element_blank(),axis.ticks.y=element_blank(),
legend.position='none'),
tooltip='text') %>%
style(hoveron='all')
#
# ## discrete
# ggplotly(
# ggplot(mapdat) +
# geom_sf(aes(fill=colorbins,
# text=sprintf("<b>%s</b><br>Count:%s<br>Income:%s",
# province,
# format(count,big.mark=','),
# paste0(format(round(income/1000000,1),big.mark=','),' M'))),
#
# color="#444444",
# alpha=0.75) + theme_bw() +
#
# # scale_fill_gradient(low='#f1eef6',
# # high='#045a8d',
# # na.value='grey.50') +
#
# scale_fill_brewer(palette='PuBu') +
#
# theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank(),
# axis.title.x=element_blank(),axis.text.x=element_blank(),axis.ticks.x=element_blank(),
# axis.title.y=element_blank(),axis.text.y=element_blank(),axis.ticks.y=element_blank()),
#
# tooltip='text') %>%
# style(hoveron='all')
#
#
#
#
#
#
#
# ggplotly(
# ggplot(mapdat) +
# geom_sf(aes(fill=colorbins,
# text=paste0("province:",province)),
#
# color='#444444',
# alpha=0.75) + theme_bw() +
#
#
# theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank(),
# axis.title.x=element_blank(),axis.text.x=element_blank(),axis.ticks.x=element_blank(),
# axis.title.y=element_blank(),axis.text.y=element_blank(),axis.ticks.y=element_blank()),
#
# tooltip=) %>%
# style(hoveron='all')