-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.R
112 lines (57 loc) · 2.05 KB
/
server.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
library(shiny)
library(leaflet)
library(RColorBrewer)
library(scales)
library(lattice)
library(dplyr)
library(rlang)
library(ggplot2)
library(ggthemes)
library(ggrepel)
library(DT)
#analyticsData<-read.csv("LifeExpectancyData.csv")
# Define server logic required to draw a histogram
function(input, output, session) {
target_year = reactive({
input$typeofyear
})
target_quo = reactive ({
parse_quosure(input$typeofvariable)
})
dftable<-reactive({
analytics=filter(dataAnalytics,Date== target_year())
arrange(analytics,desc(!!target_quo()))
})
# dftable<- reactive ({
# analyticsData%>%
# arrange(desc(!!target_quo()))
# }
dfmap<-reactive ({
analytics2<-filter(dataAnalytics,Date==target_year())
CountryData_<-left_join(Df1,analytics2,by="Country")
CountryData_%>%select(input$typeofvariable)
})
## Interactive Map liuhongyang###########################################
# Create the map
output$map <- renderLeaflet({
leaflet(geojson) %>% addTiles(urlTemplate = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png",
attribution = 'Maps by <a href="http://www.mapbox.com/">Mapbox</a>')%>%
addPolygons(stroke = FALSE, smoothFactor = 0.3, fillOpacity = 0.5,
label = paste(CountryData$Country, ":", dfmap()[,1]),
color = pal(rescale(dfmap()[,1],na.rm=TRUE))
)%>%
setView(lng = 0, lat = 40, zoom = 2) %>%
addLegend("bottomleft",pal = pal,
values =c(0:1), opacity = 0.7)
})
output$data <- renderTable({
head((dftable()[, c("Country", input$typeofvariable), drop = FALSE]) ,10)
}, rownames = TRUE)
############################
#############################
############################ liuhongyang
output$table <- DT::renderDataTable({
DT::datatable(dataAnalytics)
})
############################
}