Dosen Pengampu : Prof. Dr. Suhartono, Mkom

UIN Maulana Malik Ibrahim Malang

library(readxl)
datainflowsumatera <- read_excel(path = "sumatera.xlsx")
datainflowsumatera
## # A tibble: 10 x 10
##    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   4570   4710   5775   5514   5799   7509
##  2 Sumatera Utara  23238  25981  18120   3050  30254  34427  35617  41769  47112
##  3 Sumatera Barat   9385  11192  14056   1410  13309  14078  15312  15058  14750
##  4 Riau             3012   4447   8933   6360   7156   8211   8553  10730  10915
##  5 Kep. Riau        1426   2236   3378   2560   3218   4317   4412   5134   6077
##  6 Jambi            1868   2138   3047   5170   4978   4398   4404   5657   6486
##  7 Sumatera Sela~   7820   9126   8647  10000  10797  12752  13075  14267  14812
##  8 Bengkulu         1153   1201   2378   3260   2791   2889   3620   4150   5789
##  9 Lampung          7690   6969   3474   9450   8160   9373  12078  13415  17046
## 10 Kep. Bangka B~      0      0      0   1370   1177   1544   1164   1517   3265
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.6     v purrr   0.3.4
## v tibble  3.1.7     v dplyr   1.0.9
## 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()
datalongersumater <- datainflowsumatera %>% 
  pivot_longer(!Propinsi, names_to = "Tahun", values_to = "Kasus")
datalongersumater 
## # A tibble: 90 x 3
##    Propinsi       Tahun Kasus
##    <chr>          <chr> <dbl>
##  1 Aceh           2011   2308
##  2 Aceh           2012   2620
##  3 Aceh           2013  36337
##  4 Aceh           2014   4570
##  5 Aceh           2015   4710
##  6 Aceh           2016   5775
##  7 Aceh           2017   5514
##  8 Aceh           2018   5799
##  9 Aceh           2019   7509
## 10 Sumatera Utara 2011  23238
## # ... with 80 more rows
library(dplyr)
sumateraup2 <- select(datalongersumater, Propinsi, Kasus)
sumateraup2
## # A tibble: 90 x 2
##    Propinsi       Kasus
##    <chr>          <dbl>
##  1 Aceh            2308
##  2 Aceh            2620
##  3 Aceh           36337
##  4 Aceh            4570
##  5 Aceh            4710
##  6 Aceh            5775
##  7 Aceh            5514
##  8 Aceh            5799
##  9 Aceh            7509
## 10 Sumatera Utara 23238
## # ... with 80 more rows
library(dplyr)
sumateraup4 <- datalongersumater  %>%
    filter(Propinsi == 'Aceh') %>%
    select('Propinsi', 'Tahun', 'Kasus')
sumateraup4 
## # A tibble: 9 x 3
##   Propinsi Tahun Kasus
##   <chr>    <chr> <dbl>
## 1 Aceh     2011   2308
## 2 Aceh     2012   2620
## 3 Aceh     2013  36337
## 4 Aceh     2014   4570
## 5 Aceh     2015   4710
## 6 Aceh     2016   5775
## 7 Aceh     2017   5514
## 8 Aceh     2018   5799
## 9 Aceh     2019   7509
sumateraup5 <- datalongersumater %>%
  filter(Propinsi == 'Aceh', Tahun == '2011') %>%
 select('Propinsi', 'Tahun', 'Kasus')
sumateraup5
## # A tibble: 1 x 3
##   Propinsi Tahun Kasus
##   <chr>    <chr> <dbl>
## 1 Aceh     2011   2308
ggplot(data = datalongersumater, mapping = aes(x = Tahun, y = Kasus)) +
  geom_point() +
  facet_wrap( ~ Propinsi) +
  theme(axis.text.x = element_text(angle = 90))