Lembaga : Universitas Islam Negeri Maulana Malik Ibrahim Malang
Jurusan : Teknik Informatika
Pivot table adalah ringkasan data yang dikemas dalam tabel interaktif agar memudahkan dan membantu kamu untuk membuat laporan dan menganalisisnya dengan melihat perbandingan data yang kamu miliki.
Singkatnya, gunanya pivot table adalah untuk merangkum, mengelompokkan, mengeksplorasi, mempresentasikan, menghitung, dan menganalisa data.
library(readxl)
datainflowsulawesi <- read_excel(path = "Sulawesi.xlsx")
datainflowsulawesi
## # A tibble: 36 x 12
## Propinsi `2011` `2012` `2013` `2014` `2015` `2016` `2017` `2018` `2019`
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Aceh 2308. 2620. 36337. 4.57e3 4710. 5775. 5514. 5799. 7509.
## 2 Sumatera Utara 23238. 25981. 18120. 3.05e4 30254. 34427. 35617. 41769. 47112.
## 3 Sumatera Barat 9385. 11192. 14056. 1.41e4 13309. 14078. 15312. 15058. 14750.
## 4 Riau 3012. 4447. 8933. 6.36e3 7156. 8211. 8553. 10730. 10915.
## 5 Kep. Riau 1426. 2236. 3378. 2.56e3 3218. 4317. 4412. 5134. 6077.
## 6 Jambi 1868. 2138. 3047. 5.17e3 4978. 4398. 4404. 5657. 6486.
## 7 Sumatera Sela~ 7820. 9126. 8647. 1.00e4 10797. 12752. 13075. 14267. 14812.
## 8 Bengkulu 1153. 1201. 2378. 3.26e3 2791. 2889. 3620. 4150. 5789.
## 9 Lampung 7690. 6969. 3474. 9.45e3 8160. 9373. 12078. 13415. 17046.
## 10 Kep. Bangka B~ 0 0 0 1.37e1 1177. 1544. 1164. 1517. 3265.
## # ... with 26 more rows, and 2 more variables: `2020` <dbl>, `2021` <dbl>
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.6 v dplyr 1.0.8
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
datalongersulawesi <- datainflowsulawesi %>%
pivot_longer(!Propinsi, names_to = "Tahun", values_to = "Kasus")
datalongersulawesi
## # A tibble: 396 x 3
## Propinsi Tahun Kasus
## <chr> <chr> <dbl>
## 1 Aceh 2011 2308.
## 2 Aceh 2012 2620.
## 3 Aceh 2013 36337.
## 4 Aceh 2014 4567.
## 5 Aceh 2015 4710.
## 6 Aceh 2016 5775.
## 7 Aceh 2017 5514.
## 8 Aceh 2018 5799.
## 9 Aceh 2019 7509.
## 10 Aceh 2020 6641.
## # ... with 386 more rows
sulawesi1 <- select(datalongersulawesi, Propinsi,Kasus)
sulawesi1
## # A tibble: 396 x 2
## Propinsi Kasus
## <chr> <dbl>
## 1 Aceh 2308.
## 2 Aceh 2620.
## 3 Aceh 36337.
## 4 Aceh 4567.
## 5 Aceh 4710.
## 6 Aceh 5775.
## 7 Aceh 5514.
## 8 Aceh 5799.
## 9 Aceh 7509.
## 10 Aceh 6641.
## # ... with 386 more rows
library(dplyr)
sulawesiup2 <- datalongersulawesi %>%
filter(Propinsi == 'Sulawesi Utara') %>%
select('Propinsi', 'Tahun', 'Kasus')
sulawesiup2
## # A tibble: 11 x 3
## Propinsi Tahun Kasus
## <chr> <chr> <dbl>
## 1 Sulawesi Utara 2011 5671.
## 2 Sulawesi Utara 2012 6635.
## 3 Sulawesi Utara 2013 21646.
## 4 Sulawesi Utara 2014 7374.
## 5 Sulawesi Utara 2015 6286.
## 6 Sulawesi Utara 2016 7266.
## 7 Sulawesi Utara 2017 7044.
## 8 Sulawesi Utara 2018 7781.
## 9 Sulawesi Utara 2019 7809.
## 10 Sulawesi Utara 2020 6324.
## 11 Sulawesi Utara 2021 4671.
sulawesiup3 <- datalongersulawesi %>%
filter(Propinsi == 'Sulawesi Utara', Tahun == '2011') %>%
select('Propinsi', 'Tahun', 'Kasus')
sulawesiup3
## # A tibble: 1 x 3
## Propinsi Tahun Kasus
## <chr> <chr> <dbl>
## 1 Sulawesi Utara 2011 5671.
ggplot(data = datalongersulawesi, mapping = aes(x = Tahun, y = Kasus)) +
geom_point() +
facet_wrap( ~ Propinsi) +
theme(axis.text.x = element_text(angle = 90))
ggplot(data = datalongersulawesi, mapping = aes(x = Propinsi, y = Kasus)) +
geom_point() +
facet_wrap( ~ Tahun) +
theme(axis.text.x = element_text(angle = 90))
ggplot(data = sulawesiup2, mapping = aes(x = Tahun, y = Kasus)) +
geom_point() +
facet_wrap( ~ Propinsi) +
theme(axis.text.x = element_text(angle = 90))
ggplot(data = sulawesiup2, mapping = aes(x = Propinsi, y = Kasus)) +
geom_point() +
facet_wrap( ~ Tahun) +
theme(axis.text.x = element_text(angle = 90))
Referensi
https://www.kitalulus.com/seputar-kerja/pivot-table-adalah
https://www.bi.go.id/id/statistik/ekonomi-keuangan/ssp/indikator-pengedaran-uang.aspx