-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.R
More file actions
73 lines (63 loc) · 2.41 KB
/
app.R
File metadata and controls
73 lines (63 loc) · 2.41 KB
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
library(data.table)
library(shiny)
library(tidyverse)
dat1 = fread("half_map_dat1.csv")
dat2 = fread("half_map_dat2.csv")
data = rbind(dat1, dat2)
map_plot = function(colname){
plot = data %>%
ggplot()+
geom_polygon(aes(x=long, y=lat,group=group, fill={{colname}} %>% as.numeric()))+
scale_fill_gradient(low='#FDEBB0', high='#24966B')+
theme(panel.background = element_rect(fill='white', color='black', linetype='solid'),
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(),
strip.background = element_rect(fill="white", color="black"),
legend.title=element_text(face="bold", size=10),
strip.text = element_text(face="bold"))
return(plot)
}
ui = fluidPage(
titlePanel("서울시 지역 변수 시각화하기"),
fluidPage(
helpText("서울시 법정동의 정보를 시각화"),
selectInput("var",
label = "변수를 선택하세요",
choices = c("교통안전지수", "음식점수", "인구", "자동차등록", "주점수"),
selected = "교통안전지수"),
selectInput("year",
label = "연도를 선택하세요",
choices = c("2017", "2018", "2019"),
selected = "2017")),
mainPanel(
plotOutput(outputId = "distPlot")
)
)
server = function(input, output){
Input = reactive({
data[, input$var]
})
output$distPlot = renderPlot({
data %>%
filter(기간 == input$year) %>%
ggplot()+
geom_polygon(aes(x=long, y=lat,group=group, fill=get(Input())))+
scale_fill_gradient(low='#FDEBB0', high='#24966B')+
theme(panel.background = element_rect(fill='white', color='black', linetype='solid'),
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(),
strip.background = element_rect(fill="white", color="black"),
legend.title=element_text(face="bold", size=10),
strip.text = element_text(face="bold"))+
labs(fill = input$var)
})
}
shinyApp(ui, server)