COVID-19

COVID-19 merupakan suatu pandemi yang disebabkan oleh virus corona 2019. Informasi tentang pertumbuhan kasus COVID-19 selalu setiap hari diinformasikan baik pada media sosial dan media komunikasi lainnya. Pemerintah baik pada pusat dan daerah masing-masing selalu mengumpulkan, menyediakan, dan mempublikasikan pertumbuhan COVID-19 di Indonesia maupun di daerah. Data pertumbuhan COVID-19 tersebut berupa data mentah yang belum diolah, infografis, maupun suatu dasboard.

Dalam hal ini, saya akan melakukan eksplorasi dan analisis mengenai COVID-19 Jawa Barat menggunakan data pada API berikut https://covid19-public.digitalservice.id/api/v1/sebaran_v2/jabar


COVID-19 JAWA BARAT

DATA PREPARATION DAN LOAD PACKAGE

library(ggplot2)
library(hrbrthemes)
## Warning: package 'hrbrthemes' was built under R version 4.0.4
## NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.
##       Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and
##       if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow
library(scales)
library(httr)
library(sf)
## Warning: package 'sf' was built under R version 4.0.4
## Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v tibble  3.0.4     v dplyr   1.0.2
## v tidyr   1.1.2     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.0
## v purrr   0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x readr::col_factor() masks scales::col_factor()
## x purrr::discard()    masks scales::discard()
## x dplyr::filter()     masks stats::filter()
## x dplyr::lag()        masks stats::lag()
library(dplyr)
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
# get data

resp_cov_jabar<-
  GET("https://covid19-public.digitalservice.id/api/v1/sebaran_v2/jabar")

# status
status_code(resp_cov_jabar)
## [1] 200
names(resp_cov_jabar)
##  [1] "url"         "status_code" "headers"     "all_headers" "cookies"    
##  [6] "content"     "date"        "times"       "request"     "handle"
# raw data
raw_cov_jabar<-
  content(resp_cov_jabar, as="parsed", simplifyVector=TRUE)
names(raw_cov_jabar)
## [1] "status_code" "data"
covid_jabar_list<-
  raw_cov_jabar$data
length(covid_jabar_list)
## [1] 2
names(covid_jabar_list)
## [1] "metadata" "content"
covid_jabar_list$metadata
## $last_update
## [1] "2021-07-12, 04:28:16"
tanggal_terakhir_update<-
  covid_jabar_list$metadata[[1]]%>%
  as.Date()
tanggal_terakhir_update
## [1] "2021-07-12"
# dataset covid jabar

covid_jabar_data<-
  covid_jabar_list$content%>%
  mutate(status = as_factor(status),
         stage = as_factor(stage),
         tanggal_konfirmasi = as.Date(tanggal_konfirmasi),
         tanggal_update = as.Date(tanggal_update),
         tanggal_update_nasional = as.Date(tanggal_update_nasional))
names(covid_jabar_data)
##  [1] "id"                                "kode_kab"                         
##  [3] "nama_kab"                          "kode_kec"                         
##  [5] "nama_kec"                          "kode_kel"                         
##  [7] "nama_kel"                          "status"                           
##  [9] "stage"                             "umur"                             
## [11] "gender"                            "longitude"                        
## [13] "latitude"                          "tanggal_konfirmasi"               
## [15] "tanggal_update"                    "current_location_type"            
## [17] "current_location_district_code"    "current_location_subdistrict_code"
## [19] "current_location_village_code"     "current_location_address"         
## [21] "report_source"                     "tanggal_update_nasional"
str(covid_jabar_data)
## 'data.frame':    822518 obs. of  22 variables:
##  $ id                               : chr  "from_manual_219498" "from_manual_219500" "from_manual_219586" "from_manual_223297" ...
##  $ kode_kab                         : chr  "3271" "3271" "3271" "3271" ...
##  $ nama_kab                         : chr  "Kota Bogor" "Kota Bogor" "Kota Bogor" "Kota Bogor" ...
##  $ kode_kec                         : chr  "3271020" "3271020" "3271020" "3271020" ...
##  $ nama_kec                         : chr  "Kota Bogor Timur" "Kota Bogor Timur" "Kota Bogor Timur" "Kota Bogor Timur" ...
##  $ kode_kel                         : chr  "3271020005" "3271020005" "3271020005" "3271020005" ...
##  $ nama_kel                         : chr  "Baranangsiang" "Baranangsiang" "Baranangsiang" "Baranangsiang" ...
##  $ status                           : Factor w/ 5 levels "CONFIRMATION",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ stage                            : Factor w/ 6 levels "Selesai","Diisolasi",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ umur                             : num  38 32 66 64 53 21 30 43 42 33 ...
##  $ gender                           : chr  "Laki-laki" "Laki-laki" "Perempuan" "Laki-laki" ...
##  $ longitude                        : num  107 107 107 107 107 ...
##  $ latitude                         : num  -6.59 -6.59 -6.59 -6.59 -6.59 ...
##  $ tanggal_konfirmasi               : Date, format: "2021-01-08" "2021-01-05" ...
##  $ tanggal_update                   : Date, format: "2021-03-26" "2021-03-26" ...
##  $ current_location_type            : chr  "BMC Mayapada Hospital" "Rumah Sakit Citra Arafiq" "Dinkes Prov. Jabar" "Dinkes Prov. Jabar" ...
##  $ current_location_district_code   : chr  NA NA NA NA ...
##  $ current_location_subdistrict_code: chr  NA NA NA NA ...
##  $ current_location_village_code    : chr  NA NA NA NA ...
##  $ current_location_address         : chr  NA NA NA NA ...
##  $ report_source                    : chr  NA NA NA NA ...
##  $ tanggal_update_nasional          : Date, format: "2021-03-05" "2021-03-05" ...
# PETA Kabupaten
peta_jabar<-
  st_read("Jabar_By_Kab.geojson") %>%
  select(-contains("NO"))
## Reading layer `Jabar_By_Kab' from data source `C:\Users\aukk\Documents\project\jds\Jabar_By_Kab.geojson' using driver `GeoJSON'
## Simple feature collection with 27 features and 8 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 106.3705 ymin: -7.823398 xmax: 108.8338 ymax: -5.91377
## Geodetic CRS:  WGS 84
str(peta_jabar)
## Classes 'sf' and 'data.frame':   27 obs. of  7 variables:
##  $ OBJECTID  : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ PROVINSI  : chr  "JAWA BARAT" "JAWA BARAT" "JAWA BARAT" "JAWA BARAT" ...
##  $ KABKOT    : chr  "BOGOR" "SUKABUMI" "CIANJUR" "BANDUNG" ...
##  $ ID_KAB    : num  3201 3202 3203 3204 3205 ...
##  $ Shape_Leng: num  4.45 4.05 4.89 3.09 3.48 ...
##  $ Shape_Area: num  0.245 0.34 0.294 0.144 0.253 ...
##  $ geometry  :sfc_MULTIPOLYGON of length 27; first list element: List of 1
##   ..$ :List of 3
##   .. ..$ : num [1:10876, 1:2] 107 107 107 107 107 ...
##   .. ..$ : num [1:4, 1:2] 107.13 107.13 107.13 107.13 -6.47 ...
##   .. ..$ : num [1:3501, 1:2] 107 107 107 107 107 ...
##   ..- attr(*, "class")= chr [1:3] "XY" "MULTIPOLYGON" "sfg"
##  - attr(*, "sf_column")= chr "geometry"
##  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA
##   ..- attr(*, "names")= chr [1:6] "OBJECTID" "PROVINSI" "KABKOT" "ID_KAB" ...
# Peta kecamatan
peta_kec<-
  st_read("Jabar_By_Kec.geojson") %>%
  select(-contains("NO"))
## Reading layer `Jabar_By_Kec' from data source `C:\Users\aukk\Documents\project\jds\Jabar_By_Kec.geojson' using driver `GeoJSON'
## Simple feature collection with 627 features and 11 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 106.3705 ymin: -7.823398 xmax: 108.8338 ymax: -5.91377
## Geodetic CRS:  WGS 84
str(peta_kec)
## Classes 'sf' and 'data.frame':   627 obs. of  9 variables:
##  $ OBJECTID  : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ PROVINSI  : chr  "JAWA BARAT" "JAWA BARAT" "JAWA BARAT" "JAWA BARAT" ...
##  $ KECAMATAN : chr  "AGRABINTA" "ANDIR" "ANJATAN" "ANTAPANI" ...
##  $ KABKOT    : chr  "CIANJUR" "KOTA BANDUNG" "INDRAMAYU" "KOTA BANDUNG" ...
##  $ ID_KAB    : num  3203 3273 3212 3273 3212 ...
##  $ ID_KEC    : num  3203010 3273180 3212210 3273141 3212171 ...
##  $ Shape_Leng: num  0.873 0.128 0.532 0.104 0.286 ...
##  $ Shape_Area: num  0.016108 0.000341 0.006864 0.000341 0.002766 ...
##  $ geometry  :sfc_MULTIPOLYGON of length 627; first list element: List of 1
##   ..$ :List of 7
##   .. ..$ : num [1:1504, 1:2] 107 107 107 107 107 ...
##   .. ..$ : num [1:7, 1:2] 107 107 107 107 107 ...
##   .. ..$ : num [1:34, 1:2] 107 107 107 107 107 ...
##   .. ..$ : num [1:4, 1:2] 106.8 106.8 106.8 106.8 -7.4 ...
##   .. ..$ : num [1:4, 1:2] 106.81 106.81 106.81 106.81 -7.41 ...
##   .. ..$ : num [1:6, 1:2] 107 107 107 107 107 ...
##   .. ..$ : num [1:4, 1:2] 106.81 106.81 106.81 106.81 -7.43 ...
##   ..- attr(*, "class")= chr [1:3] "XY" "MULTIPOLYGON" "sfg"
##  - attr(*, "sf_column")= chr "geometry"
##  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA
##   ..- attr(*, "names")= chr [1:8] "OBJECTID" "PROVINSI" "KECAMATAN" "KABKOT" ...
# Peta Kelurahan
peta_kel<-
  st_read("Jabar_By_Desa.geojson") %>%
  select(-contains("NO"))
## Reading layer `Jabar_By_Desa' from data source `C:\Users\aukk\Documents\project\jds\Jabar_By_Desa.geojson' using driver `GeoJSON'
## Simple feature collection with 5995 features and 14 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 106.3705 ymin: -7.823398 xmax: 108.8338 ymax: -5.91377
## Geodetic CRS:  WGS 84
str(peta_kel)
## Classes 'sf' and 'data.frame':   5995 obs. of  11 variables:
##  $ OBJECTID  : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ PROVINSI  : chr  "JAWA BARAT" "JAWA BARAT" "JAWA BARAT" "JAWA BARAT" ...
##  $ KECAMATAN : chr  "NANGGUNG" "NANGGUNG" "NANGGUNG" "NANGGUNG" ...
##  $ DESA      : chr  "MALASARI" "BANTAR KARET" "CISARUA" "CURUG BITUNG" ...
##  $ KABKOT    : chr  "BOGOR" "BOGOR" "BOGOR" "BOGOR" ...
##  $ ID2012    : chr  "3201010001" "3201010002" "3201010003" "3201010004" ...
##  $ ID_KAB    : num  3201 3201 3201 3201 3201 ...
##  $ ID_KEC    : num  3201010 3201010 3201010 3201010 3201010 ...
##  $ Shape_Leng: num  0.374 0.387 0.197 0.2 0.113 ...
##  $ Shape_Area: num  0.004994 0.003062 0.00152 0.000917 0.000552 ...
##  $ geometry  :sfc_MULTIPOLYGON of length 5995; first list element: List of 1
##   ..$ :List of 1
##   .. ..$ : num [1:873, 1:2] 107 107 107 107 107 ...
##   ..- attr(*, "class")= chr [1:3] "XY" "MULTIPOLYGON" "sfg"
##  - attr(*, "sf_column")= chr "geometry"
##  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA
##   ..- attr(*, "names")= chr [1:10] "OBJECTID" "PROVINSI" "KECAMATAN" "DESA" ...

DATA DENGAN STATUS TERKOFIRMASI

# konfirmasi by kab total


konfirmasi_covid_jabar_data<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(status=="CONFIRMATION")
names(konfirmasi_covid_jabar_data)
##  [1] "id"                      "kode_kab"               
##  [3] "nama_kab"                "kode_kec"               
##  [5] "nama_kec"                "kode_kel"               
##  [7] "nama_kel"                "status"                 
##  [9] "stage"                   "umur"                   
## [11] "gender"                  "longitude"              
## [13] "latitude"                "tanggal_konfirmasi"     
## [15] "tanggal_update"          "tanggal_update_nasional"
konfirmasi_covid_jabar_data_summarise<-
  konfirmasi_covid_jabar_data%>%
  group_by(nama_kab)%>%
  summarise(Total=n())
## `summarise()` ungrouping output (override with `.groups` argument)
konfirmasi_covid_jabar_data_summarise
## # A tibble: 28 x 2
##    nama_kab                Total
##    <chr>                   <int>
##  1 Jawa Barat               2165
##  2 Kabupaten Bandung       23895
##  3 Kabupaten Bandung Barat 11919
##  4 Kabupaten Bekasi        34271
##  5 Kabupaten Bogor         23588
##  6 Kabupaten Ciamis         7459
##  7 Kabupaten Cianjur        4910
##  8 Kabupaten Cirebon       15538
##  9 Kabupaten Garut         18027
## 10 Kabupaten Indramayu     10732
## # ... with 18 more rows
# stage by kab total

konfirmasi_covid_jabar_data_by_stage_summarise<- 
  konfirmasi_covid_jabar_data%>%
  group_by(nama_kab, stage)%>%
  summarise(Total=n())
## `summarise()` regrouping output by 'nama_kab' (override with `.groups` argument)
stage_konfirmasi_total<-
  konfirmasi_covid_jabar_data_by_stage_summarise %>%
  pivot_wider(names_from = stage, values_from =c(Total))
stage_konfirmasi_total
## # A tibble: 28 x 4
## # Groups:   nama_kab [28]
##    nama_kab                Selesai Diisolasi Meninggal
##    <chr>                     <int>     <int>     <int>
##  1 Jawa Barat                 2155         1         9
##  2 Kabupaten Bandung         19230      4371       294
##  3 Kabupaten Bandung Barat   10452      1309       158
##  4 Kabupaten Bekasi          30240      3963        68
##  5 Kabupaten Bogor           20148      3353        87
##  6 Kabupaten Ciamis           5960      1288       211
##  7 Kabupaten Cianjur          4463       433        14
##  8 Kabupaten Cirebon         12138      3178       222
##  9 Kabupaten Garut            9942      7619       466
## 10 Kabupaten Indramayu        9421       988       323
## # ... with 18 more rows
# Konfirmasi by kab hari terupdate 
tanggal_terupdate<- as_date(max(konfirmasi_covid_jabar_data$tanggal_update_nasional))
tanggal_terupdate
## [1] "2021-07-10"
konfirmasi_covid_jabar_data_hari<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(status=="CONFIRMATION", tanggal_update_nasional==tanggal_terupdate)

konfirmasi_covid_jabar_data_hari_summarise<-
  konfirmasi_covid_jabar_data_hari%>%
  group_by(nama_kab)%>%
  summarise(Hari_Terakhir=n())
## `summarise()` ungrouping output (override with `.groups` argument)
konfirmasi_covid_jabar_data_hari_summarise
## # A tibble: 21 x 2
##    nama_kab                Hari_Terakhir
##    <chr>                           <int>
##  1 Kabupaten Bandung                 418
##  2 Kabupaten Bandung Barat            16
##  3 Kabupaten Bekasi                   25
##  4 Kabupaten Bogor                   476
##  5 Kabupaten Ciamis                  348
##  6 Kabupaten Cirebon                 503
##  7 Kabupaten Indramayu               100
##  8 Kabupaten Karawang                933
##  9 Kabupaten Kuningan                 96
## 10 Kabupaten Majalengka              324
## # ... with 11 more rows
# stage by kab hari update

konfirmasi_covid_jabar_data_by_stage_hari_summarise<- 
  konfirmasi_covid_jabar_data_hari%>%
  group_by(nama_kab, stage)%>%
  summarise(Hari_Terakhir=n())
## `summarise()` regrouping output by 'nama_kab' (override with `.groups` argument)
stage_konfirmasi_hari<-
  konfirmasi_covid_jabar_data_by_stage_hari_summarise %>%
  pivot_wider(names_from = stage, values_from = Hari_Terakhir)
stage_konfirmasi_hari[is.na(stage_konfirmasi_hari)]=0
stage_konfirmasi_hari
## # A tibble: 21 x 3
## # Groups:   nama_kab [21]
##    nama_kab                Diisolasi Selesai
##    <chr>                       <int>   <int>
##  1 Kabupaten Bandung             418       0
##  2 Kabupaten Bandung Barat        16       0
##  3 Kabupaten Bekasi               25       0
##  4 Kabupaten Bogor               476       0
##  5 Kabupaten Ciamis              348       0
##  6 Kabupaten Cirebon             503       0
##  7 Kabupaten Indramayu           100       0
##  8 Kabupaten Karawang            933       0
##  9 Kabupaten Kuningan             96       0
## 10 Kabupaten Majalengka          324       0
## # ... with 11 more rows
# Konfirmasi by kab pekan terakhir

tanggal_terupdate1 <-
  tanggal_terupdate - days(7)

konfirmasi_covid_jabar_data_pekan<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  mutate(year= year(tanggal_update_nasional))%>%
  filter(status=="CONFIRMATION", year==2021, tanggal_update_nasional > tanggal_terupdate1)


konfirmasi_covid_jabar_data_pekan_summarise<-
  konfirmasi_covid_jabar_data_pekan%>%
  group_by(nama_kab)%>%
  summarise(Satu_Minggu_Trkahir=n())
## `summarise()` ungrouping output (override with `.groups` argument)
konfirmasi_covid_jabar_data_pekan_summarise
## # A tibble: 27 x 2
##    nama_kab                Satu_Minggu_Trkahir
##    <chr>                                 <int>
##  1 Kabupaten Bandung                      3423
##  2 Kabupaten Bandung Barat                 914
##  3 Kabupaten Bekasi                       3335
##  4 Kabupaten Bogor                        2199
##  5 Kabupaten Ciamis                       1193
##  6 Kabupaten Cianjur                       202
##  7 Kabupaten Cirebon                      2617
##  8 Kabupaten Garut                        2561
##  9 Kabupaten Indramayu                     574
## 10 Kabupaten Karawang                     4451
## # ... with 17 more rows
# stage by kab pekan update
konfirmasi_covid_jabar_data_by_stage_pekan_summarise<- 
  konfirmasi_covid_jabar_data_pekan%>%
  group_by(nama_kab, stage)%>%
  summarise(Satu_Minggu_Terakhir=n())
## `summarise()` regrouping output by 'nama_kab' (override with `.groups` argument)
stage_konfirmasi_pekan<-
  konfirmasi_covid_jabar_data_by_stage_pekan_summarise %>%
  pivot_wider(names_from = stage, values_from = Satu_Minggu_Terakhir)
stage_konfirmasi_pekan[is.na(stage_konfirmasi_pekan)]=0
stage_konfirmasi_pekan
## # A tibble: 27 x 4
## # Groups:   nama_kab [27]
##    nama_kab                Diisolasi Meninggal Selesai
##    <chr>                       <int>     <int>   <int>
##  1 Kabupaten Bandung            3421         2       0
##  2 Kabupaten Bandung Barat       911         3       0
##  3 Kabupaten Bekasi             3335         0       0
##  4 Kabupaten Bogor              2199         0       0
##  5 Kabupaten Ciamis             1193         0       0
##  6 Kabupaten Cianjur             202         0       0
##  7 Kabupaten Cirebon            2617         0       0
##  8 Kabupaten Garut              2561         0       0
##  9 Kabupaten Indramayu           560        14       0
## 10 Kabupaten Karawang           4420        31       0
## # ... with 17 more rows

DATA DENGAN STATUS SUSPECT

# suspect by kab total

suspect_covid_jabar_data<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(status=="SUSPECT")
names(suspect_covid_jabar_data)
##  [1] "id"                      "kode_kab"               
##  [3] "nama_kab"                "kode_kec"               
##  [5] "nama_kec"                "kode_kel"               
##  [7] "nama_kel"                "status"                 
##  [9] "stage"                   "umur"                   
## [11] "gender"                  "longitude"              
## [13] "latitude"                "tanggal_konfirmasi"     
## [15] "tanggal_update"          "tanggal_update_nasional"
suspect_covid_jabar_data_summarise<-
  suspect_covid_jabar_data%>%
  group_by(kode_kab)%>%
  summarise(Total=n())
## `summarise()` ungrouping output (override with `.groups` argument)
suspect_covid_jabar_data_summarise
## # A tibble: 27 x 2
##    kode_kab Total
##    <chr>    <int>
##  1 3201      2051
##  2 3202      1861
##  3 3203      3024
##  4 3204      4866
##  5 3205      6615
##  6 3206      1579
##  7 3207       135
##  8 3208      2100
##  9 3209       158
## 10 3210        88
## # ... with 17 more rows
# stage by kab total

suspect_covid_jabar_data_by_stage_summarise<- 
  suspect_covid_jabar_data%>%
  group_by(kode_kab, stage)%>%
  summarise(Total=n())
## `summarise()` regrouping output by 'kode_kab' (override with `.groups` argument)
stage_suspect_total<-
  suspect_covid_jabar_data_by_stage_summarise %>%
  pivot_wider(names_from = stage, values_from =c(Total))
stage_suspect_total[is.na(stage_suspect_total)]=0
stage_suspect_total
## # A tibble: 27 x 7
## # Groups:   kode_kab [27]
##    kode_kab Selesai Diisolasi Meninggal Discarded Dikarantina  `NA`
##    <chr>      <int>     <int>     <int>     <int>       <int> <int>
##  1 3201           5       281         2      1684          79     0
##  2 3202           0       536         1      1324           0     0
##  3 3203           0       198        45      2779           2     0
##  4 3204           0       808         6      4039          13     0
##  5 3205           0       777         3      5835           0     0
##  6 3206           0         1         0      1578           0     0
##  7 3207           0        35         1        99           0     0
##  8 3208           0       253         6      1841           0     0
##  9 3209           0        60         7        90           1     0
## 10 3210           0        28         0        60           0     0
## # ... with 17 more rows
# Suspect by kab hari terupdate 
tanggal_terupdate<- as_date(max(suspect_covid_jabar_data$tanggal_update_nasional))
tanggal_terupdate
## [1] "2021-07-11"
suspect_covid_jabar_data_hari<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(status=="SUSPECT", tanggal_update_nasional==tanggal_terupdate)

suspect_covid_jabar_data_hari_summarise<-
  suspect_covid_jabar_data_hari%>%
  group_by(kode_kab)%>%
  summarise(Hari_Terakhir=n())
## `summarise()` ungrouping output (override with `.groups` argument)
suspect_covid_jabar_data_hari_summarise
## # A tibble: 5 x 2
##   kode_kab Hari_Terakhir
##   <chr>            <int>
## 1 3204                 7
## 2 3214                 1
## 3 3217                 9
## 4 3277                13
## 5 3279                41
# stage by kab hari update

suspect_covid_jabar_data_by_stage_hari_summarise<- 
  suspect_covid_jabar_data_hari%>%
  group_by(kode_kab, stage)%>%
  summarise(Hari_Terakhir=n())
## `summarise()` regrouping output by 'kode_kab' (override with `.groups` argument)
stage_suspect_hari<-
  suspect_covid_jabar_data_by_stage_hari_summarise %>%
  pivot_wider(names_from = stage, values_from = Hari_Terakhir)
stage_suspect_hari[is.na(stage_suspect_hari)]=0
stage_suspect_hari
## # A tibble: 5 x 3
## # Groups:   kode_kab [5]
##   kode_kab Diisolasi Discarded
##   <chr>        <int>     <int>
## 1 3204             1         6
## 2 3214             0         1
## 3 3217             9         0
## 4 3277            12         1
## 5 3279            39         2
# Suspect by kab pekan terakhir

tanggal_terupdate1 <-
  tanggal_terupdate - days(7)

suspect_covid_jabar_data_pekan<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  mutate(year= year(tanggal_update_nasional))%>%
  filter(status=="SUSPECT", year==2021, tanggal_update_nasional > tanggal_terupdate1)


suspect_covid_jabar_data_pekan_summarise<-
  suspect_covid_jabar_data_pekan%>%
  group_by(kode_kab)%>%
  summarise(Satu_Minggu_Trkahir=n())
## `summarise()` ungrouping output (override with `.groups` argument)
suspect_covid_jabar_data_pekan_summarise
## # A tibble: 15 x 2
##    kode_kab Satu_Minggu_Trkahir
##    <chr>                  <int>
##  1 3201                       1
##  2 3202                       4
##  3 3203                      85
##  4 3204                     143
##  5 3205                       2
##  6 3208                      39
##  7 3211                       6
##  8 3212                       5
##  9 3214                      53
## 10 3217                     155
## 11 3271                    1372
## 12 3273                      95
## 13 3275                     184
## 14 3277                     618
## 15 3279                     321
# stage by kab pekan update
suspect_covid_jabar_data_by_stage_pekan_summarise<- 
  suspect_covid_jabar_data_pekan%>%
  group_by(kode_kab, stage)%>%
  summarise(Satu_Minggu_Terakhir=n())
## `summarise()` regrouping output by 'kode_kab' (override with `.groups` argument)
stage_suspect_pekan<-
  suspect_covid_jabar_data_by_stage_pekan_summarise %>%
  pivot_wider(names_from = stage, values_from = Satu_Minggu_Terakhir)
stage_suspect_pekan[is.na(stage_suspect_pekan)]=0
stage_suspect_pekan
## # A tibble: 15 x 5
## # Groups:   kode_kab [15]
##    kode_kab Discarded Diisolasi Meninggal Dikarantina
##    <chr>        <int>     <int>     <int>       <int>
##  1 3201             1         0         0           0
##  2 3202             0         4         0           0
##  3 3203            62        23         0           0
##  4 3204            78        65         0           0
##  5 3205             2         0         0           0
##  6 3208            18        21         0           0
##  7 3211             2         4         0           0
##  8 3212             5         0         0           0
##  9 3214            34        19         0           0
## 10 3217            91        64         0           0
## 11 3271          1346         2        24           0
## 12 3273            49        46         0           0
## 13 3275           184         0         0           0
## 14 3277           247       364         0           7
## 15 3279            72       249         0           0

DATA DENGAN STATUS CLOSECONTACT

# closekontak by kab total

closekontak_covid_jabar_data<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(status=="CLOSECONTACT")
names(closekontak_covid_jabar_data)
##  [1] "id"                      "kode_kab"               
##  [3] "nama_kab"                "kode_kec"               
##  [5] "nama_kec"                "kode_kel"               
##  [7] "nama_kel"                "status"                 
##  [9] "stage"                   "umur"                   
## [11] "gender"                  "longitude"              
## [13] "latitude"                "tanggal_konfirmasi"     
## [15] "tanggal_update"          "tanggal_update_nasional"
closekontak_covid_jabar_data_summarise<-
  closekontak_covid_jabar_data%>%
  group_by(kode_kab)%>%
  summarise(Total=n())
## `summarise()` ungrouping output (override with `.groups` argument)
closekontak_covid_jabar_data_summarise
## # A tibble: 27 x 2
##    kode_kab Total
##    <chr>    <int>
##  1 3201     12088
##  2 3202      5512
##  3 3203      7047
##  4 3204     11477
##  5 3205     18111
##  6 3206       173
##  7 3207      2801
##  8 3208      7428
##  9 3209      2384
## 10 3210       301
## # ... with 17 more rows
# stage by kab total

closekontak_covid_jabar_data_by_stage_summarise<- 
  closekontak_covid_jabar_data%>%
  group_by(kode_kab, stage)%>%
  summarise(Total=n())
## `summarise()` regrouping output by 'kode_kab' (override with `.groups` argument)
stage_closekontak_total<-
  closekontak_covid_jabar_data_by_stage_summarise %>%
  pivot_wider(names_from = stage, values_from =c(Total))
stage_closekontak_total[is.na(stage_closekontak_total)]=0
stage_closekontak_total
## # A tibble: 27 x 6
## # Groups:   kode_kab [27]
##    kode_kab Selesai Diisolasi Meninggal Discarded Dikarantina
##    <chr>      <int>     <int>     <int>     <int>       <int>
##  1 3201          45         6         2     10391        1644
##  2 3202           0         0         0      3521        1991
##  3 3203           0         0         0      5788        1259
##  4 3204           0         0         0      6949        4528
##  5 3205           0         0         0     17374         737
##  6 3206           0         0         0       168           5
##  7 3207           0         0         0      2778          23
##  8 3208           0         0         0      7340          88
##  9 3209           0         0         0       577        1807
## 10 3210           0         0         0        86         215
## # ... with 17 more rows
# Closekontak by kab hari terupdate 
tanggal_terupdate<- as_date(max(closekontak_covid_jabar_data$tanggal_update_nasional))
tanggal_terupdate
## [1] "2021-07-11"
closekontak_covid_jabar_data_hari<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(status=="CLOSECONTACT", tanggal_update_nasional==tanggal_terupdate)

closekontak_covid_jabar_data_hari_summarise<-
  closekontak_covid_jabar_data_hari%>%
  group_by(kode_kab)%>%
  summarise(Hari_Terakhir=n())
## `summarise()` ungrouping output (override with `.groups` argument)
closekontak_covid_jabar_data_hari_summarise
## # A tibble: 8 x 2
##   kode_kab Hari_Terakhir
##   <chr>            <int>
## 1 3203                22
## 2 3204                42
## 3 3211                14
## 4 3214                 6
## 5 3217                69
## 6 3275               200
## 7 3277                23
## 8 3279                49
# stage by kab hari update

closekontak_covid_jabar_data_by_stage_hari_summarise<- 
  closekontak_covid_jabar_data_hari%>%
  group_by(kode_kab, stage)%>%
  summarise(Hari_Terakhir=n())
## `summarise()` regrouping output by 'kode_kab' (override with `.groups` argument)
stage_closekontak_hari<-
  closekontak_covid_jabar_data_by_stage_hari_summarise %>%
  pivot_wider(names_from = stage, values_from = Hari_Terakhir)
stage_closekontak_hari[is.na(stage_closekontak_hari)]=0
stage_closekontak_hari
## # A tibble: 8 x 3
## # Groups:   kode_kab [8]
##   kode_kab Dikarantina Discarded
##   <chr>          <int>     <int>
## 1 3203              22         0
## 2 3204              36         6
## 3 3211              14         0
## 4 3214               0         6
## 5 3217              55        14
## 6 3275               0       200
## 7 3277              21         2
## 8 3279              49         0
# Closekontak by kab pekan terakhir

tanggal_terupdate1 <-
  tanggal_terupdate - days(7)

closekontak_covid_jabar_data_pekan<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  mutate(year= year(tanggal_update_nasional))%>%
  filter(status=="CLOSECONTACT", year==2021, tanggal_update_nasional > tanggal_terupdate1)


closekontak_covid_jabar_data_pekan_summarise<-
  closekontak_covid_jabar_data_pekan%>%
  group_by(kode_kab)%>%
  summarise(Satu_Minggu_Trkahir=n())
## `summarise()` ungrouping output (override with `.groups` argument)
closekontak_covid_jabar_data_pekan_summarise
## # A tibble: 13 x 2
##    kode_kab Satu_Minggu_Trkahir
##    <chr>                  <int>
##  1 3201                       3
##  2 3203                     411
##  3 3204                     289
##  4 3205                       6
##  5 3211                      45
##  6 3212                      20
##  7 3214                     119
##  8 3217                     183
##  9 3271                    4760
## 10 3273                      87
## 11 3275                    4879
## 12 3277                     487
## 13 3279                     485
# stage by kab pekan update
closekontak_covid_jabar_data_by_stage_pekan_summarise<- 
  closekontak_covid_jabar_data_pekan%>%
  group_by(kode_kab, stage)%>%
  summarise(Satu_Minggu_Terakhir=n())
## `summarise()` regrouping output by 'kode_kab' (override with `.groups` argument)
stage_closekontak_pekan<-
  closekontak_covid_jabar_data_by_stage_pekan_summarise %>%
  pivot_wider(names_from = stage, values_from = Satu_Minggu_Terakhir)
stage_closekontak_pekan[is.na(stage_closekontak_pekan)]=0
stage_closekontak_pekan
## # A tibble: 13 x 3
## # Groups:   kode_kab [13]
##    kode_kab Dikarantina Discarded
##    <chr>          <int>     <int>
##  1 3201               3         0
##  2 3203             178       233
##  3 3204             171       118
##  4 3205               0         6
##  5 3211              45         0
##  6 3212               1        19
##  7 3214              73        46
##  8 3217             113        70
##  9 3271               2      4758
## 10 3273              19        68
## 11 3275               0      4879
## 12 3277             325       162
## 13 3279             184       301

DATA DENGAN STATUS PROBABLE

# probable by kab total

probable_covid_jabar_data<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(status=="CLOSECONTACT")
names(probable_covid_jabar_data)
##  [1] "id"                      "kode_kab"               
##  [3] "nama_kab"                "kode_kec"               
##  [5] "nama_kec"                "kode_kel"               
##  [7] "nama_kel"                "status"                 
##  [9] "stage"                   "umur"                   
## [11] "gender"                  "longitude"              
## [13] "latitude"                "tanggal_konfirmasi"     
## [15] "tanggal_update"          "tanggal_update_nasional"
probable_covid_jabar_data_summarise<-
  probable_covid_jabar_data%>%
  group_by(kode_kab)%>%
  summarise(Total=n())
## `summarise()` ungrouping output (override with `.groups` argument)
probable_covid_jabar_data_summarise
## # A tibble: 27 x 2
##    kode_kab Total
##    <chr>    <int>
##  1 3201     12088
##  2 3202      5512
##  3 3203      7047
##  4 3204     11477
##  5 3205     18111
##  6 3206       173
##  7 3207      2801
##  8 3208      7428
##  9 3209      2384
## 10 3210       301
## # ... with 17 more rows
# stage by kab total

probable_covid_jabar_data_by_stage_summarise<- 
  probable_covid_jabar_data%>%
  group_by(kode_kab, stage)%>%
  summarise(Total=n())
## `summarise()` regrouping output by 'kode_kab' (override with `.groups` argument)
stage_probable_total<-
  probable_covid_jabar_data_by_stage_summarise %>%
  pivot_wider(names_from = stage, values_from =c(Total))
stage_probable_total[is.na(stage_probable_total)]=0
stage_probable_total
## # A tibble: 27 x 6
## # Groups:   kode_kab [27]
##    kode_kab Selesai Diisolasi Meninggal Discarded Dikarantina
##    <chr>      <int>     <int>     <int>     <int>       <int>
##  1 3201          45         6         2     10391        1644
##  2 3202           0         0         0      3521        1991
##  3 3203           0         0         0      5788        1259
##  4 3204           0         0         0      6949        4528
##  5 3205           0         0         0     17374         737
##  6 3206           0         0         0       168           5
##  7 3207           0         0         0      2778          23
##  8 3208           0         0         0      7340          88
##  9 3209           0         0         0       577        1807
## 10 3210           0         0         0        86         215
## # ... with 17 more rows
# Probable by kab hari terupdate 
tanggal_terupdate<- as_date(max(probable_covid_jabar_data$tanggal_update_nasional))
tanggal_terupdate
## [1] "2021-07-11"
probable_covid_jabar_data_hari<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(status=="CLOSECONTACT", tanggal_update_nasional==tanggal_terupdate)

probable_covid_jabar_data_hari_summarise<-
  probable_covid_jabar_data_hari%>%
  group_by(kode_kab)%>%
  summarise(Hari_Terakhir=n())
## `summarise()` ungrouping output (override with `.groups` argument)
probable_covid_jabar_data_hari_summarise
## # A tibble: 8 x 2
##   kode_kab Hari_Terakhir
##   <chr>            <int>
## 1 3203                22
## 2 3204                42
## 3 3211                14
## 4 3214                 6
## 5 3217                69
## 6 3275               200
## 7 3277                23
## 8 3279                49
# stage by kab hari update

probable_covid_jabar_data_by_stage_hari_summarise<- 
  probable_covid_jabar_data_hari%>%
  group_by(kode_kab, stage)%>%
  summarise(Hari_Terakhir=n())
## `summarise()` regrouping output by 'kode_kab' (override with `.groups` argument)
stage_probable_hari<-
  probable_covid_jabar_data_by_stage_hari_summarise %>%
  pivot_wider(names_from = stage, values_from = Hari_Terakhir)
stage_probable_hari[is.na(stage_probable_hari)]=0
stage_probable_hari
## # A tibble: 8 x 3
## # Groups:   kode_kab [8]
##   kode_kab Dikarantina Discarded
##   <chr>          <int>     <int>
## 1 3203              22         0
## 2 3204              36         6
## 3 3211              14         0
## 4 3214               0         6
## 5 3217              55        14
## 6 3275               0       200
## 7 3277              21         2
## 8 3279              49         0
# Probable by kab pekan terakhir

tanggal_terupdate1 <-
  tanggal_terupdate - days(7)

probable_covid_jabar_data_pekan<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  mutate(year= year(tanggal_update_nasional))%>%
  filter(status=="CLOSECONTACT", year==2021, tanggal_update_nasional > tanggal_terupdate1)


probable_covid_jabar_data_pekan_summarise<-
  probable_covid_jabar_data_pekan%>%
  group_by(kode_kab)%>%
  summarise(Satu_Minggu_Trkahir=n())
## `summarise()` ungrouping output (override with `.groups` argument)
probable_covid_jabar_data_pekan_summarise
## # A tibble: 13 x 2
##    kode_kab Satu_Minggu_Trkahir
##    <chr>                  <int>
##  1 3201                       3
##  2 3203                     411
##  3 3204                     289
##  4 3205                       6
##  5 3211                      45
##  6 3212                      20
##  7 3214                     119
##  8 3217                     183
##  9 3271                    4760
## 10 3273                      87
## 11 3275                    4879
## 12 3277                     487
## 13 3279                     485
# stage by kab pekan update
probable_covid_jabar_data_by_stage_pekan_summarise<- 
  probable_covid_jabar_data_pekan%>%
  group_by(kode_kab, stage)%>%
  summarise(Satu_Minggu_Terakhir=n())
## `summarise()` regrouping output by 'kode_kab' (override with `.groups` argument)
stage_probable_pekan<-
  probable_covid_jabar_data_by_stage_pekan_summarise %>%
  pivot_wider(names_from = stage, values_from = Satu_Minggu_Terakhir)
stage_probable_pekan[is.na(stage_probable_pekan)]=0
stage_probable_pekan
## # A tibble: 13 x 3
## # Groups:   kode_kab [13]
##    kode_kab Dikarantina Discarded
##    <chr>          <int>     <int>
##  1 3201               3         0
##  2 3203             178       233
##  3 3204             171       118
##  4 3205               0         6
##  5 3211              45         0
##  6 3212               1        19
##  7 3214              73        46
##  8 3217             113        70
##  9 3271               2      4758
## 10 3273              19        68
## 11 3275               0      4879
## 12 3277             325       162
## 13 3279             184       301

VISUASLISASI DIISOLASI

# Covid Diisolasi for visualisasi

covid_konfirmasi_diisolasi_jabar_data<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Diisolasi", status== "CONFIRMATION")%>%
  group_by(kode_kab)%>%
  mutate(n=n())%>%
  drop_na()

covid_konfirmasi_diisolasi_jabar_summarise<-
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Diisolasi", status== "CONFIRMATION")%>%
  group_by(kode_kab)%>%
  summarise(n=n())%>%
  rename(ID_KAB = kode_kab)%>%
  filter(ID_KAB!="32")%>%
  mutate(ID_KAB = as.numeric(ID_KAB))
## `summarise()` ungrouping output (override with `.groups` argument)
covid_konfirmasi_diisolasi_jabar_summarise
## # A tibble: 27 x 2
##    ID_KAB     n
##     <dbl> <int>
##  1   3201  3353
##  2   3202   921
##  3   3203   433
##  4   3204  4371
##  5   3205  7619
##  6   3206  1293
##  7   3207  1288
##  8   3208  3169
##  9   3209  3178
## 10   3210  2121
## # ... with 17 more rows
# Join Data dengan Peta

## Bagusnya join datanya berdasarkan koordinat latitude dan longitude responden, seperti ini:
## covid_diisolasi_jabar_data <- st_as_sf(covid_diisolasi_jabar_data, coords=c("longitude", "latitude"))
## st_crs(covid_diisolasi_jabar_data) <- st_crs(peta_jabar) 
## covid_diisolasi_jabar_final <- st_join(peta_jabar, covid_diisolasi_jabar_data, left= FALSE) 
## covid_diisolasi_jabar_final <- covid_diisolasi_jabar_final %>% group_by(nama_kab) %>% summarise(n= n())

# Karena kalau gitu lama, jadi menggunakan ini


covid_konfirmasi_diisolasi_jabar_final<-
  full_join(peta_jabar, covid_konfirmasi_diisolasi_jabar_summarise, by= "ID_KAB")%>%
  select(-contains("Shape_"))
covid_konfirmasi_diisolasi_jabar_final[is.na(covid_konfirmasi_diisolasi_jabar_final)]=0
covid_konfirmasi_diisolasi_jabar_final
## Simple feature collection with 27 features and 5 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 106.3705 ymin: -7.823398 xmax: 108.8338 ymax: -5.91377
## Geodetic CRS:  WGS 84
## First 10 features:
##    OBJECTID   PROVINSI      KABKOT ID_KAB    n                       geometry
## 1         1 JAWA BARAT       BOGOR   3201 3353 MULTIPOLYGON (((106.9708 -6...
## 2         2 JAWA BARAT    SUKABUMI   3202  921 MULTIPOLYGON (((106.7415 -6...
## 3         3 JAWA BARAT     CIANJUR   3203  433 MULTIPOLYGON (((107.2302 -6...
## 4         4 JAWA BARAT     BANDUNG   3204 4371 MULTIPOLYGON (((107.7331 -6...
## 5         5 JAWA BARAT       GARUT   3205 7619 MULTIPOLYGON (((107.9182 -6...
## 6         6 JAWA BARAT TASIKMALAYA   3206 1293 MULTIPOLYGON (((108.3549 -7...
## 7         7 JAWA BARAT      CIAMIS   3207 1288 MULTIPOLYGON (((108.4415 -7...
## 8         8 JAWA BARAT PANGANDARAN   3218  303 MULTIPOLYGON (((108.6694 -7...
## 9         9 JAWA BARAT    KUNINGAN   3208 3169 MULTIPOLYGON (((108.4211 -6...
## 10       10 JAWA BARAT     CIREBON   3209 3178 MULTIPOLYGON (((108.685 -6....
ggplot(covid_konfirmasi_diisolasi_jabar_final) +
  geom_sf(aes(fill=n)) +
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"),
        line = element_blank(),
        rect = element_blank(), 
        axis.text = element_blank(),
        axis.ticks.length = unit(0, "cm"), 
        legend.justification=c(0, 0), 
        legend.position = c(0, 0), 
        panel.spacing = unit(0, "lines"),
        plot.margin = unit(c(0, 0, 0, 0), "lines"),
        complete = TRUE) +
  viridis::scale_fill_viridis("Banyaknya Pasien Diisolasi")+
  geom_sf_label(aes(label = KABKOT, fill=n), size=2)+
  labs(title = "Data Kasus Terkonfirmasi Pasien Aktif COVID-19",
       subtitle = "Pasien Diisolasi KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi",
       x = NULL,
       y = NULL)
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

ggplot(covid_konfirmasi_diisolasi_jabar_final, aes(x = reorder(KABKOT, n), y = n))+
  geom_bar(stat = "identity", fill= "brown", alpha = 0.5)+
  coord_flip()+
  labs(title = "Data Kasus Terkonfirmasi Pasien Aktif COVID-19",
       subtitle = "Pasien Diisolasi KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi")+
  ylab("Banyaknya Pasien")+
  xlab("Nama Kabupaten/Kota")+
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"))


# Covid Diisolasi for visualisasi

covid_suspect_diisolasi_jabar_data<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Diisolasi", status== "SUSPECT")%>%
  group_by(kode_kab)%>%
  mutate(n=n())

covid_suspect_diisolasi_jabar_summarise<-
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Diisolasi", status== "SUSPECT")%>%
  group_by(kode_kab)%>%
  summarise(n=n())%>%
  rename(ID_KAB = kode_kab)%>%
  filter(ID_KAB!="32")%>%
  mutate(ID_KAB = as.numeric(ID_KAB))
## `summarise()` ungrouping output (override with `.groups` argument)
covid_suspect_diisolasi_jabar_summarise
## # A tibble: 26 x 2
##    ID_KAB     n
##     <dbl> <int>
##  1   3201   281
##  2   3202   536
##  3   3203   198
##  4   3204   808
##  5   3205   777
##  6   3206     1
##  7   3207    35
##  8   3208   253
##  9   3209    60
## 10   3210    28
## # ... with 16 more rows
# Join Data dengan Peta

covid_suspect_diisolasi_jabar_final<-
  full_join(peta_jabar, covid_suspect_diisolasi_jabar_summarise, by= "ID_KAB")%>%
  select(-contains("Shape_"))

covid_suspect_diisolasi_jabar_final[is.na(covid_suspect_diisolasi_jabar_final)] = 0
covid_suspect_diisolasi_jabar_final
## Simple feature collection with 27 features and 5 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 106.3705 ymin: -7.823398 xmax: 108.8338 ymax: -5.91377
## Geodetic CRS:  WGS 84
## First 10 features:
##    OBJECTID   PROVINSI      KABKOT ID_KAB   n                       geometry
## 1         1 JAWA BARAT       BOGOR   3201 281 MULTIPOLYGON (((106.9708 -6...
## 2         2 JAWA BARAT    SUKABUMI   3202 536 MULTIPOLYGON (((106.7415 -6...
## 3         3 JAWA BARAT     CIANJUR   3203 198 MULTIPOLYGON (((107.2302 -6...
## 4         4 JAWA BARAT     BANDUNG   3204 808 MULTIPOLYGON (((107.7331 -6...
## 5         5 JAWA BARAT       GARUT   3205 777 MULTIPOLYGON (((107.9182 -6...
## 6         6 JAWA BARAT TASIKMALAYA   3206   1 MULTIPOLYGON (((108.3549 -7...
## 7         7 JAWA BARAT      CIAMIS   3207  35 MULTIPOLYGON (((108.4415 -7...
## 8         8 JAWA BARAT PANGANDARAN   3218 121 MULTIPOLYGON (((108.6694 -7...
## 9         9 JAWA BARAT    KUNINGAN   3208 253 MULTIPOLYGON (((108.4211 -6...
## 10       10 JAWA BARAT     CIREBON   3209  60 MULTIPOLYGON (((108.685 -6....
ggplot(covid_suspect_diisolasi_jabar_final) +
  geom_sf(aes(fill=n)) +
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"),
        line = element_blank(),
        rect = element_blank(), 
        axis.text = element_blank(),
        axis.ticks.length = unit(0, "cm"), 
        legend.justification=c(0, 0), 
        legend.position = c(0, 0), 
        panel.spacing = unit(0, "lines"),
        plot.margin = unit(c(0, 0, 0, 0), "lines"),
        complete = TRUE) +
  viridis::scale_fill_viridis("Banyaknya Pasien Diisolasi")+
  geom_sf_label(aes(label = KABKOT, fill=n), size=2)+
  labs(title = "Data Kasus Suspect Pasien Aktif COVID-19",
       subtitle = "Pasien Diisolasi KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi",
       x = NULL,
       y = NULL)
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

ggplot(covid_suspect_diisolasi_jabar_final, aes(x = reorder(KABKOT, n), y = n))+
  geom_bar(stat = "identity", fill= "brown", alpha = 0.5)+
  coord_flip()+
  labs(title = "Data Kasus Suspect Pasien Aktif COVID-19",
       subtitle = "Pasien Diisolasi KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi")+
  ylab("Banyaknya Pasien")+
  xlab("Nama Kabupaten/Kota")+
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"))


# Covid Diisolasi for visualisasi

covid_closekontak_diisolasi_jabar_data<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Dikarantina", status== "CLOSECONTACT")%>%
  group_by(kode_kab)%>%
  mutate(n=n())

covid_closekontak_diisolasi_jabar_summarise<-
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Dikarantina", status== "CLOSECONTACT")%>%
  group_by(kode_kab)%>%
  summarise(n=n())%>%
  rename(ID_KAB = kode_kab)%>%
  filter(ID_KAB!="32")%>%
  mutate(ID_KAB= as.numeric(ID_KAB))
## `summarise()` ungrouping output (override with `.groups` argument)
covid_closekontak_diisolasi_jabar_summarise
## # A tibble: 27 x 2
##    ID_KAB     n
##     <dbl> <int>
##  1   3201  1644
##  2   3202  1991
##  3   3203  1259
##  4   3204  4528
##  5   3205   737
##  6   3206     5
##  7   3207    23
##  8   3208    88
##  9   3209  1807
## 10   3210   215
## # ... with 17 more rows
# Join Data dengan Peta

covid_closekontak_diisolasi_jabar_final<-
  full_join(peta_jabar, covid_closekontak_diisolasi_jabar_summarise, by= "ID_KAB")%>%
  select(-contains("Shape_"))
covid_closekontak_diisolasi_jabar_final[is.na(covid_closekontak_diisolasi_jabar_final)]=0
covid_closekontak_diisolasi_jabar_final
## Simple feature collection with 27 features and 5 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 106.3705 ymin: -7.823398 xmax: 108.8338 ymax: -5.91377
## Geodetic CRS:  WGS 84
## First 10 features:
##    OBJECTID   PROVINSI      KABKOT ID_KAB    n                       geometry
## 1         1 JAWA BARAT       BOGOR   3201 1644 MULTIPOLYGON (((106.9708 -6...
## 2         2 JAWA BARAT    SUKABUMI   3202 1991 MULTIPOLYGON (((106.7415 -6...
## 3         3 JAWA BARAT     CIANJUR   3203 1259 MULTIPOLYGON (((107.2302 -6...
## 4         4 JAWA BARAT     BANDUNG   3204 4528 MULTIPOLYGON (((107.7331 -6...
## 5         5 JAWA BARAT       GARUT   3205  737 MULTIPOLYGON (((107.9182 -6...
## 6         6 JAWA BARAT TASIKMALAYA   3206    5 MULTIPOLYGON (((108.3549 -7...
## 7         7 JAWA BARAT      CIAMIS   3207   23 MULTIPOLYGON (((108.4415 -7...
## 8         8 JAWA BARAT PANGANDARAN   3218  656 MULTIPOLYGON (((108.6694 -7...
## 9         9 JAWA BARAT    KUNINGAN   3208   88 MULTIPOLYGON (((108.4211 -6...
## 10       10 JAWA BARAT     CIREBON   3209 1807 MULTIPOLYGON (((108.685 -6....
ggplot(covid_closekontak_diisolasi_jabar_final) +
  geom_sf(aes(fill=n)) +
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"),
        line = element_blank(),
        rect = element_blank(), 
        axis.text = element_blank(),
        axis.ticks.length = unit(0, "cm"), 
        legend.justification=c(0, 0), 
        legend.position = c(0, 0), 
        panel.spacing = unit(0, "lines"),
        plot.margin = unit(c(0, 0, 0, 0), "lines"),
        complete = TRUE) +
  viridis::scale_fill_viridis("Banyaknya Pasien Diisolasi")+
  geom_sf_label(aes(label = KABKOT, fill=n), size=2)+
  labs(title = "Data Kasus Closecontact Pasien Aktif COVID-19",
       subtitle = "Pasien Diisolasi KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi",
       x = NULL,
       y = NULL)
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

ggplot(covid_closekontak_diisolasi_jabar_final, aes(x = reorder(KABKOT, n), y = n))+
  geom_bar(stat = "identity", fill= "brown", alpha = 0.5)+
  coord_flip()+
  labs(title = "Data Kasus Closecontact Pasien Aktif COVID-19",
       subtitle = "Pasien Dikarantina KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi")+
  ylab("Banyaknya Pasien")+
  xlab("Nama Kabupaten/Kota")+
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"))


# Covid Diisolasi for visualisasi

covid_probable_diisolasi_jabar_data<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Diisolasi", status== "PROBABLE")%>%
  group_by(kode_kab)%>%
  mutate(n=n())

covid_probable_diisolasi_jabar_summarise<-
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Diisolasi", status== "PROBABLE")%>%
  group_by(kode_kab)%>%
  summarise(n=n())%>%
  rename(ID_KAB = kode_kab)%>%
  filter(ID_KAB!="32")%>%
  mutate(ID_KAB = as.numeric(ID_KAB))
## `summarise()` ungrouping output (override with `.groups` argument)
covid_probable_diisolasi_jabar_summarise
## # A tibble: 17 x 2
##    ID_KAB     n
##     <dbl> <int>
##  1   3201    16
##  2   3202    52
##  3   3203    19
##  4   3204     4
##  5   3205     1
##  6   3207     2
##  7   3208    16
##  8   3209     3
##  9   3211     1
## 10   3212     5
## 11   3214     1
## 12   3216   173
## 13   3217    10
## 14   3218     2
## 15   3275    89
## 16   3277     7
## 17   3279    14
# Join Data dengan Peta

covid_probable_diisolasi_jabar_final<-
  full_join(peta_jabar, covid_probable_diisolasi_jabar_summarise, by= "ID_KAB")%>%
  select(-contains("Shape_"))
covid_probable_diisolasi_jabar_final[is.na(covid_probable_diisolasi_jabar_final)]=0
covid_probable_diisolasi_jabar_final
## Simple feature collection with 27 features and 5 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 106.3705 ymin: -7.823398 xmax: 108.8338 ymax: -5.91377
## Geodetic CRS:  WGS 84
## First 10 features:
##    OBJECTID   PROVINSI      KABKOT ID_KAB  n                       geometry
## 1         1 JAWA BARAT       BOGOR   3201 16 MULTIPOLYGON (((106.9708 -6...
## 2         2 JAWA BARAT    SUKABUMI   3202 52 MULTIPOLYGON (((106.7415 -6...
## 3         3 JAWA BARAT     CIANJUR   3203 19 MULTIPOLYGON (((107.2302 -6...
## 4         4 JAWA BARAT     BANDUNG   3204  4 MULTIPOLYGON (((107.7331 -6...
## 5         5 JAWA BARAT       GARUT   3205  1 MULTIPOLYGON (((107.9182 -6...
## 6         6 JAWA BARAT TASIKMALAYA   3206  0 MULTIPOLYGON (((108.3549 -7...
## 7         7 JAWA BARAT      CIAMIS   3207  2 MULTIPOLYGON (((108.4415 -7...
## 8         8 JAWA BARAT PANGANDARAN   3218  2 MULTIPOLYGON (((108.6694 -7...
## 9         9 JAWA BARAT    KUNINGAN   3208 16 MULTIPOLYGON (((108.4211 -6...
## 10       10 JAWA BARAT     CIREBON   3209  3 MULTIPOLYGON (((108.685 -6....
ggplot(covid_probable_diisolasi_jabar_final) +
  geom_sf(aes(fill=n)) +
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"),
        line = element_blank(),
        rect = element_blank(), 
        axis.text = element_blank(),
        axis.ticks.length = unit(0, "cm"), 
        legend.justification=c(0, 0), 
        legend.position = c(0, 0), 
        panel.spacing = unit(0, "lines"),
        plot.margin = unit(c(0, 0, 0, 0), "lines"),
        complete = TRUE) +
  viridis::scale_fill_viridis("Banyaknya Pasien Diisolasi")+
  geom_sf_label(aes(label = KABKOT, fill=n), size=2)+
  labs(title = "Data Kasus Probable Pasien Aktif COVID-19",
       subtitle = "Pasien Diisolasi KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi",
       x = NULL,
       y = NULL)
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

ggplot(covid_probable_diisolasi_jabar_final, aes(x = reorder(KABKOT, n), y = n))+
  geom_bar(stat = "identity", fill= "brown", alpha = 0.5)+
  coord_flip()+
  labs(title = "Data Kasus Probable Pasien Aktif COVID-19",
       subtitle = "Pasien Diisolasi KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi")+
  ylab("Banyaknya Pasien")+
  xlab("Nama Kabupaten/Kota")+
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"))


VISUALISASI MENINGGAL

# Covid Disolasi for visualisasi

covid_konfirmasi_meninggal_jabar_data<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Meninggal", status== "CONFIRMATION")%>%
  group_by(kode_kab)%>%
  mutate(n=n())

covid_konfirmasi_meninggal_jabar_summarise<-
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Meninggal", status== "CONFIRMATION")%>%
  group_by(kode_kab)%>%
  summarise(n=n())%>%
  filter(kode_kab !="32")%>%
  rename(ID_KAB = kode_kab)%>%
  mutate(ID_KAB = as.numeric(ID_KAB))
## `summarise()` ungrouping output (override with `.groups` argument)
covid_konfirmasi_meninggal_jabar_summarise
## # A tibble: 28 x 2
##    ID_KAB     n
##     <dbl> <int>
##  1     NA     1
##  2   3201    87
##  3   3202    66
##  4   3203    14
##  5   3204   294
##  6   3205   466
##  7   3206   126
##  8   3207   211
##  9   3208    15
## 10   3209   222
## # ... with 18 more rows
# Join data dengan peta
covid_konfirmasi_meninggal_jabar_final<-
  full_join(peta_jabar, covid_konfirmasi_meninggal_jabar_summarise, by= "ID_KAB")

covid_konfirmasi_meninggal_jabar_final[is.na(covid_konfirmasi_meninggal_jabar_final)]=0
covid_konfirmasi_meninggal_jabar_final
## Simple feature collection with 28 features and 7 fields (with 1 geometry empty)
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 106.3705 ymin: -7.823398 xmax: 108.8338 ymax: -5.91377
## Geodetic CRS:  WGS 84
## First 10 features:
##    OBJECTID   PROVINSI      KABKOT ID_KAB Shape_Leng Shape_Area   n
## 1         1 JAWA BARAT       BOGOR   3201   4.450488 0.24474031  87
## 2         2 JAWA BARAT    SUKABUMI   3202   4.046777 0.34048048  66
## 3         3 JAWA BARAT     CIANJUR   3203   4.890595 0.29407572  14
## 4         4 JAWA BARAT     BANDUNG   3204   3.093005 0.14360665 294
## 5         5 JAWA BARAT       GARUT   3205   3.480848 0.25302534 466
## 6         6 JAWA BARAT TASIKMALAYA   3206   3.811662 0.22094821 126
## 7         7 JAWA BARAT      CIAMIS   3207   3.131695 0.13047727 211
## 8         8 JAWA BARAT PANGANDARAN   3218   2.491501 0.09307806  55
## 9         9 JAWA BARAT    KUNINGAN   3208   1.921314 0.09702479  15
## 10       10 JAWA BARAT     CIREBON   3209   2.756094 0.08733455 222
##                          geometry
## 1  MULTIPOLYGON (((106.9708 -6...
## 2  MULTIPOLYGON (((106.7415 -6...
## 3  MULTIPOLYGON (((107.2302 -6...
## 4  MULTIPOLYGON (((107.7331 -6...
## 5  MULTIPOLYGON (((107.9182 -6...
## 6  MULTIPOLYGON (((108.3549 -7...
## 7  MULTIPOLYGON (((108.4415 -7...
## 8  MULTIPOLYGON (((108.6694 -7...
## 9  MULTIPOLYGON (((108.4211 -6...
## 10 MULTIPOLYGON (((108.685 -6....
ggplot(covid_konfirmasi_meninggal_jabar_final) +
  geom_sf(aes(fill= n))+
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"),
        line = element_blank(),
        rect = element_blank(), 
        axis.text = element_blank(),
        axis.ticks.length = unit(0, "cm"), 
        legend.justification=c(0, 0), 
        legend.position = c(0, 0), 
        panel.spacing = unit(0, "lines"),
        plot.margin = unit(c(0, 0, 0, 0), "lines"),
        complete = TRUE) +
  viridis::scale_fill_viridis("Banyaknya Pasien Meninggal")+
  geom_sf_label(aes(label = KABKOT, fill=n), size=2)+
  labs(title = "Data Kasus Terkonfirmasi Pasien COVID-19",
       subtitle = "Pasien Meninggal KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi",
       x = NULL,
       y = NULL)
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data
## Warning: Removed 1 rows containing missing values (geom_label).

ggplot(covid_konfirmasi_meninggal_jabar_final, aes(x = reorder(KABKOT, n), y = n))+
  geom_bar(stat = "identity", fill= "brown", alpha = 0.5)+
  coord_flip()+
  labs(title = "Data Kasus Terkonfirmasi Pasien COVID-19",
       subtitle = "Pasien Meninggal KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi")+
  ylab("Banyaknya Kasus")+
  xlab("Nama Kabupaten/Kota")+
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"))


# Covid Disolasi for visualisasi

covid_suspect_meninggal_jabar_data<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Meninggal", status== "SUSPECT")%>%
  group_by(kode_kab)%>%
  mutate(n=n())

covid_suspect_meninggal_jabar_summarise<-
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Meninggal", status== "SUSPECT")%>%
  group_by(kode_kab)%>%
  summarise(n=n())%>%
  filter(kode_kab !="32")%>%
  rename(ID_KAB = kode_kab)%>%
  mutate(ID_KAB = as.numeric(ID_KAB))
## `summarise()` ungrouping output (override with `.groups` argument)
covid_suspect_meninggal_jabar_summarise
## # A tibble: 20 x 2
##    ID_KAB     n
##     <dbl> <int>
##  1   3201     2
##  2   3202     1
##  3   3203    45
##  4   3204     6
##  5   3205     3
##  6   3207     1
##  7   3208     6
##  8   3209     7
##  9   3212     3
## 10   3213     3
## 11   3214     8
## 12   3215     6
## 13   3216     7
## 14   3217     2
## 15   3218     6
## 16   3271   171
## 17   3275   373
## 18   3276     1
## 19   3277    14
## 20   3279     7
# Join data dengan peta
covid_suspect_meninggal_jabar_final<-
  full_join(peta_jabar, covid_suspect_meninggal_jabar_summarise, by= "ID_KAB")
covid_suspect_meninggal_jabar_final[is.na(covid_suspect_meninggal_jabar_final)]=0
covid_suspect_meninggal_jabar_final
## Simple feature collection with 27 features and 7 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 106.3705 ymin: -7.823398 xmax: 108.8338 ymax: -5.91377
## Geodetic CRS:  WGS 84
## First 10 features:
##    OBJECTID   PROVINSI      KABKOT ID_KAB Shape_Leng Shape_Area  n
## 1         1 JAWA BARAT       BOGOR   3201   4.450488 0.24474031  2
## 2         2 JAWA BARAT    SUKABUMI   3202   4.046777 0.34048048  1
## 3         3 JAWA BARAT     CIANJUR   3203   4.890595 0.29407572 45
## 4         4 JAWA BARAT     BANDUNG   3204   3.093005 0.14360665  6
## 5         5 JAWA BARAT       GARUT   3205   3.480848 0.25302534  3
## 6         6 JAWA BARAT TASIKMALAYA   3206   3.811662 0.22094821  0
## 7         7 JAWA BARAT      CIAMIS   3207   3.131695 0.13047727  1
## 8         8 JAWA BARAT PANGANDARAN   3218   2.491501 0.09307806  6
## 9         9 JAWA BARAT    KUNINGAN   3208   1.921314 0.09702479  6
## 10       10 JAWA BARAT     CIREBON   3209   2.756094 0.08733455  7
##                          geometry
## 1  MULTIPOLYGON (((106.9708 -6...
## 2  MULTIPOLYGON (((106.7415 -6...
## 3  MULTIPOLYGON (((107.2302 -6...
## 4  MULTIPOLYGON (((107.7331 -6...
## 5  MULTIPOLYGON (((107.9182 -6...
## 6  MULTIPOLYGON (((108.3549 -7...
## 7  MULTIPOLYGON (((108.4415 -7...
## 8  MULTIPOLYGON (((108.6694 -7...
## 9  MULTIPOLYGON (((108.4211 -6...
## 10 MULTIPOLYGON (((108.685 -6....
ggplot(covid_suspect_meninggal_jabar_final) +
  geom_sf(aes(fill= n))+
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"),
        line = element_blank(),
        rect = element_blank(), 
        axis.text = element_blank(),
        axis.ticks.length = unit(0, "cm"), 
        legend.justification=c(0, 0), 
        legend.position = c(0, 0), 
        panel.spacing = unit(0, "lines"),
        plot.margin = unit(c(0, 0, 0, 0), "lines"),
        complete = TRUE) +
  viridis::scale_fill_viridis("Banyaknya Pasien Meninggal")+
  geom_sf_label(aes(label = KABKOT, fill=n), size=2)+
  labs(title = "Data Kasus Suspect Pasien COVID-19",
       subtitle = "Pasien Meninggal KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi",
       x = NULL,
       y = NULL)
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

ggplot(covid_suspect_meninggal_jabar_final, aes(x = reorder(KABKOT, n), y = n))+
  geom_bar(stat = "identity", fill= "brown", alpha = 0.5)+
  coord_flip()+
  labs(title = "Data Kasus Suspect Pasien COVID-19",
       subtitle = "Pasien Meninggal KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi")+
  ylab("Banyaknya Kasus")+
  xlab("Nama Kabupaten/Kota")+
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"))


# Covid Disolasi for visualisasi

covid_probable_meninggal_jabar_data<- 
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Meninggal", status== "PROBABLE")%>%
  group_by(kode_kab)%>%
  mutate(n=n())

covid_probable_meninggal_jabar_summarise<-
  covid_jabar_data%>%
  select(-c(report_source,contains("current_")))%>%
  filter(stage=="Meninggal", status== "PROBABLE")%>%
  group_by(kode_kab)%>%
  summarise(n=n())%>%
  filter(kode_kab !="32")%>%
  rename(ID_KAB = kode_kab)%>%
  mutate(ID_KAB = as.numeric(ID_KAB))
## `summarise()` ungrouping output (override with `.groups` argument)
covid_probable_meninggal_jabar_summarise
## # A tibble: 20 x 2
##    ID_KAB     n
##     <dbl> <int>
##  1   3201     4
##  2   3202   120
##  3   3203    52
##  4   3204    77
##  5   3205     5
##  6   3208    21
##  7   3209    16
##  8   3212   121
##  9   3213     1
## 10   3214    15
## 11   3215    89
## 12   3216     9
## 13   3217    44
## 14   3218    10
## 15   3271    55
## 16   3272    10
## 17   3273     1
## 18   3275   286
## 19   3277    42
## 20   3279    32
# Join data dengan peta
covid_probable_meninggal_jabar_final<-
  full_join(peta_jabar, covid_probable_meninggal_jabar_summarise, by= "ID_KAB")
covid_probable_meninggal_jabar_final[is.na(covid_probable_meninggal_jabar_final)]=0
covid_probable_meninggal_jabar_final
## Simple feature collection with 27 features and 7 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 106.3705 ymin: -7.823398 xmax: 108.8338 ymax: -5.91377
## Geodetic CRS:  WGS 84
## First 10 features:
##    OBJECTID   PROVINSI      KABKOT ID_KAB Shape_Leng Shape_Area   n
## 1         1 JAWA BARAT       BOGOR   3201   4.450488 0.24474031   4
## 2         2 JAWA BARAT    SUKABUMI   3202   4.046777 0.34048048 120
## 3         3 JAWA BARAT     CIANJUR   3203   4.890595 0.29407572  52
## 4         4 JAWA BARAT     BANDUNG   3204   3.093005 0.14360665  77
## 5         5 JAWA BARAT       GARUT   3205   3.480848 0.25302534   5
## 6         6 JAWA BARAT TASIKMALAYA   3206   3.811662 0.22094821   0
## 7         7 JAWA BARAT      CIAMIS   3207   3.131695 0.13047727   0
## 8         8 JAWA BARAT PANGANDARAN   3218   2.491501 0.09307806  10
## 9         9 JAWA BARAT    KUNINGAN   3208   1.921314 0.09702479  21
## 10       10 JAWA BARAT     CIREBON   3209   2.756094 0.08733455  16
##                          geometry
## 1  MULTIPOLYGON (((106.9708 -6...
## 2  MULTIPOLYGON (((106.7415 -6...
## 3  MULTIPOLYGON (((107.2302 -6...
## 4  MULTIPOLYGON (((107.7331 -6...
## 5  MULTIPOLYGON (((107.9182 -6...
## 6  MULTIPOLYGON (((108.3549 -7...
## 7  MULTIPOLYGON (((108.4415 -7...
## 8  MULTIPOLYGON (((108.6694 -7...
## 9  MULTIPOLYGON (((108.4211 -6...
## 10 MULTIPOLYGON (((108.685 -6....
ggplot(covid_probable_meninggal_jabar_final) +
  geom_sf(aes(fill= n))+
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"),
        line = element_blank(),
        rect = element_blank(), 
        axis.text = element_blank(),
        axis.ticks.length = unit(0, "cm"), 
        legend.justification=c(0, 0), 
        legend.position = c(0, 0), 
        panel.spacing = unit(0, "lines"),
        plot.margin = unit(c(0, 0, 0, 0), "lines"),
        complete = TRUE) +
  viridis::scale_fill_viridis("Banyaknya Pasien Meninggal")+
  geom_sf_label(aes(label = KABKOT, fill=n), size=2)+
  labs(title = "Data Kasus Probable Pasien COVID-19",
       subtitle = "Pasien Meninggal KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi",
       x = NULL,
       y = NULL)
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

ggplot(covid_probable_meninggal_jabar_final, aes(x = reorder(KABKOT, n), y = n))+
  geom_bar(stat = "identity", fill= "brown", alpha = 0.5)+
  coord_flip()+
  labs(title = "Data Kasus Probable Pasien COVID-19",
       subtitle = "Pasien Meninggal KAB/KOTA di JAWA BARAT",
       caption = "by : Arwan Zhagi")+
  ylab("Banyaknya Kasus")+
  xlab("Nama Kabupaten/Kota")+
  theme(plot.title = element_text(color = "black",size = 17, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(size = 10, face = "bold"))


VISUALISASI KOTA BANDUNG

COMING SOON