-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeodashboard_jpa.Rmd
145 lines (118 loc) · 2.88 KB
/
geodashboard_jpa.Rmd
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
title: "Jabodetabek Property Analysis Dashboard"
output:
flexdashboard::flex_dashboard:
theme: readable
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(glue)
library(scales)
library(sf)
library(plotly)
library(leaflet)
library(leaflet.extras)
# read data
idn <- st_read(dsn = "shp", layer = "idn")
df <- read.csv("data/listings.csv")
perum <- read.csv('data/perumahan.csv')
# aggregate
df_agg <- df %>%
mutate(
harga_m2 = harga / m2
) %>%
group_by(kota, kecamatan) %>%
summarise(harga_m2 = median(harga_m2),
total_listings= n()) %>%
ungroup() %>%
left_join(idn, by = c("kota" = "NAME_2", "kecamatan" = "NAME_3")) %>%
st_as_sf()
```
Column {.tabset}
-------------------------------------
### Distribution of House Price/m2 for each Kecamatan
```{r}
pal <- colorNumeric(palette = "YlOrRd", domain = df_agg$harga_m2)
labels <- glue::glue("
<b>{df_agg$kecamatan}, {df_agg$kota}</b>:<br> {round(df_agg$harga_m2/1e6, 2)} jt/m2 <br> Total house listed: {df_agg$total_listings}") %>% lapply(htmltools::HTML)
border <- df_agg %>%
filter(NAME_1 == "Jakarta Raya") %>%
group_by(NAME_1) %>%
summarise()
leaflet(df_agg) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addPolygons(
label = labels,
labelOptions = labelOptions(
style = list(
"font-size"="13px",
"background-color"="black",
"color"="white"
)
),
weight = 2,
color = "white",
fillOpacity = .8,
fillColor = ~pal(harga_m2),
highlight = highlightOptions(
weight = 5,
color = "black",
bringToFront = TRUE,
sendToBack = TRUE,
opacity = 0.8)
) %>%
addPolylines(
data = border,
color = "darkred",
opacity = .8,
weight = 3
) %>%
addLegend(
pal = pal,
values = ~harga_m2,
opacity = 1,
title = "Harga/m2",
position = "bottomright"
) %>%
setView(lat = -6.225337, lng = 106.841086, zoom=11.2)
```
### Housing Heatmap
```{r}
library(leaflet.extras)
leaflet(perum) %>%
addProviderTiles(providers$CartoDB.Voyager) %>%
addCircles(
label = ~perumahan,
color = "red"
) %>%
addHeatmap(
radius = 10
)%>%
setView(lat = -6.225337, lng = 106.841086, zoom=11.2)
```
Column
-------------------------------------
### Average Price per Kecamatan Table
```{r}
library(DT)
data <- df_agg %>%
as.data.frame() %>%
arrange(desc(harga_m2)) %>%
select(kota, kecamatan, harga_m2) %>%
mutate(harga_m2 = number(harga_m2, big.mark = ",")) %>%
rename(
Kota = kota,
Kecamatan = kecamatan,
`Price/m2` = harga_m2
)
DT::datatable(
data,
extensions = "Buttons",
options = list(
pageLength = 25,
dom = 'Bfrtip',
buttons = c('csv','excel','pdf')
)
)
```