-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdashboard-geo.Rmd
131 lines (109 loc) · 2.75 KB
/
dashboard-geo.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
---
title: "Analisis Pasar Properti Jabodetabek"
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")
# 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()
```
Disclaimer {.sidebar}
-------------------------------------
**Disclaimer**:
Dashboard ini dibuat hanya untuk kepentingan edukasi membuat dashboard dan peta interaktif menggunakan R.
Data yang ditampilkan merupakan hasil sample cepat dari ±10,000 rumah yang dijual di salah satu situs marketplace di Indonesia pada September 2020. Nilai yang di tampilkan belum tentu merepresentasikan harga yang sebenarnya.
Column
-------------------------------------
### Sebaran Harga Rumah per Kecamatan
```{r}
pal <- colorNumeric(palette = "Reds", 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"
) %>% lapply(htmltools::HTML)
border <- df_agg %>%
filter(NAME_1 == "Jakarta Raya") %>%
group_by(NAME_1) %>%
summarise()
leaflet(df_agg) %>%
addProviderTiles(providers$CartoDB.DarkMatter) %>%
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"
) %>%
fitBounds(106.686211, -6.370783, 106.972824, -6.089036)
```
Column
-------------------------------------
### Tabel Rata-rata Harga per Kecamatan
```{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,
`Harga/m2` = harga_m2
)
DT::datatable(
data,
extensions = "Buttons",
options = list(
pageLength = 25,
dom = 'Bfrtip',
buttons = c('csv','excel','pdf')
)
)
```