Mengakses API covid.go.id

library(httr)
## Warning: package 'httr' was built under R version 4.2.2
set_config(config(ssl_verifypeer = 0L))
resp <- GET("https://storage.googleapis.com/dqlab-dataset/update.json")

# Status Code
status_code(resp)
## [1] 200
# Status Code - 2
identical(resp$status_code, status_code(resp))
## [1] TRUE
# Header API
headers(resp)
## $`x-guploader-uploadid`
## [1] "ADPycduPUGCTwtpfQrAu_ApGlgQ88QsGLkUIPEeenGRe-86RAYLlJ5MdxiLaGFFij7VYe8TeZOfKMUlb8gEGO4ex-Avx4llMVQdj"
## 
## $`x-goog-generation`
## [1] "1654513959565478"
## 
## $`x-goog-metageneration`
## [1] "1"
## 
## $`x-goog-stored-content-encoding`
## [1] "identity"
## 
## $`x-goog-stored-content-length`
## [1] "311897"
## 
## $`x-goog-hash`
## [1] "crc32c=GMMqEA=="
## 
## $`x-goog-hash`
## [1] "md5=8aR/820+lfYyWNlv5bLUOQ=="
## 
## $`x-goog-storage-class`
## [1] "STANDARD"
## 
## $`accept-ranges`
## [1] "bytes"
## 
## $`content-length`
## [1] "311897"
## 
## $server
## [1] "UploadServer"
## 
## $date
## [1] "Sat, 24 Dec 2022 06:00:16 GMT"
## 
## $expires
## [1] "Sat, 24 Dec 2022 07:00:16 GMT"
## 
## $`cache-control`
## [1] "public, max-age=3600"
## 
## $`last-modified`
## [1] "Mon, 06 Jun 2022 11:12:39 GMT"
## 
## $etag
## [1] "\"f1a47ff36d3e95f63258d96fe5b2d439\""
## 
## $`content-type`
## [1] "application/json"
## 
## $age
## [1] "0"
## 
## $`alt-svc`
## [1] "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
## 
## attr(,"class")
## [1] "insensitive" "list"

Extracting the contents of the Response

cov_id_raw <- content(resp, as = "parsed", simplifyVector = TRUE)

Extracting the contents of the Response - Pt 2

length(cov_id_raw)
## [1] 2
names(cov_id_raw)
## [1] "data"   "update"
cov_id_update <- cov_id_raw$update

Data Analysis

lapply(cov_id_update, names)
## $penambahan
## [1] "jumlah_positif"   "jumlah_meninggal" "jumlah_sembuh"    "jumlah_dirawat"  
## [5] "tanggal"          "created"         
## 
## $harian
##  [1] "key_as_string"        "key"                  "doc_count"           
##  [4] "jumlah_meninggal"     "jumlah_sembuh"        "jumlah_positif"      
##  [7] "jumlah_dirawat"       "jumlah_positif_kum"   "jumlah_sembuh_kum"   
## [10] "jumlah_meninggal_kum" "jumlah_dirawat_kum"  
## 
## $total
## [1] "jumlah_positif"   "jumlah_dirawat"   "jumlah_sembuh"    "jumlah_meninggal"
cov_id_update$penambahan$tanggal
## [1] "2022-05-14"
cov_id_update$penambahan$jumlah_sembuh
## [1] 416
cov_id_update$penambahan$jumlah_meninggal
## [1] 5
cov_id_update$total$jumlah_positif
## [1] 6050519
cov_id_update$total$jumlah_meninggal
## [1] 156453

What about Covid in West Java?

library(httr)
set_config(config(ssl_verifypeer = 0L))
resp_jabar <- GET("https://storage.googleapis.com/dqlab-dataset/prov_detail_JAWA_BARAT.json")
cov_jabar_raw <- content(resp_jabar, as = "parsed", simplifyVector = TRUE)


names(cov_jabar_raw)
##  [1] "last_date"            "provinsi"             "kasus_total"         
##  [4] "kasus_tanpa_tgl"      "kasus_dengan_tgl"     "meninggal_persen"    
##  [7] "meninggal_tanpa_tgl"  "meninggal_dengan_tgl" "sembuh_persen"       
## [10] "sembuh_tanpa_tgl"     "sembuh_dengan_tgl"    "list_perkembangan"   
## [13] "data"
cov_jabar_raw$kasus_total
## [1] 1105134
cov_jabar_raw$meninggal_persen
## [1] 1.425619
cov_jabar_raw$sembuh_persen
## [1] 98.28238

• What is the total number of COVID-19 cases in West Java? • What is the percentage of deaths from COVID-19 in West Java? • What is the percentage of the cure rate from COVID-19 in West Java?

Get full of information

# Seeing the Development of Covid in West Java
cov_jabar <- cov_jabar_raw$list_perkembangan
# see type of data
str(cov_jabar)
## 'data.frame':    785 obs. of  9 variables:
##  $ tanggal                     : num  1.58e+12 1.58e+12 1.58e+12 1.58e+12 1.58e+12 ...
##  $ KASUS                       : int  1 1 1 1 0 0 0 0 0 1 ...
##  $ MENINGGAL                   : int  1 0 0 0 0 0 0 0 1 0 ...
##  $ SEMBUH                      : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ DIRAWAT_OR_ISOLASI          : int  0 1 1 1 0 0 0 0 -1 1 ...
##  $ AKUMULASI_KASUS             : int  1 2 3 4 4 4 4 4 4 5 ...
##  $ AKUMULASI_SEMBUH            : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ AKUMULASI_MENINGGAL         : int  1 1 1 1 1 1 1 1 2 2 ...
##  $ AKUMULASI_DIRAWAT_OR_ISOLASI: int  0 1 2 3 3 3 3 3 2 3 ...
# Show a couple of data
head(cov_jabar)
##        tanggal KASUS MENINGGAL SEMBUH DIRAWAT_OR_ISOLASI AKUMULASI_KASUS
## 1 1.583194e+12     1         1      0                  0               1
## 2 1.583280e+12     1         0      0                  1               2
## 3 1.583366e+12     1         0      0                  1               3
## 4 1.583453e+12     1         0      0                  1               4
## 5 1.583539e+12     0         0      0                  0               4
## 6 1.583626e+12     0         0      0                  0               4
##   AKUMULASI_SEMBUH AKUMULASI_MENINGGAL AKUMULASI_DIRAWAT_OR_ISOLASI
## 1                0                   1                            0
## 2                0                   1                            1
## 3                0                   1                            2
## 4                0                   1                            3
## 5                0                   1                            3
## 6                0                   1                            3

The Data

#set libraray yang dibutuhkan
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.2.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
#membuat variabel dataset baru
new_cov_jabar <-
  cov_jabar %>% 
#menghapus kolom
  select(-contains("DIRAWAT_OR_ISOLASI")) %>% 
  select(-starts_with("AKUMULASI")) %>% 
#mengubah nama kolom
  rename(
    kasus_baru = KASUS,
    meninggal = MENINGGAL,
    sembuh = SEMBUH
    ) %>% 
#memperbaiki data kolom tanggal
  mutate(
    tanggal = as.POSIXct(tanggal / 1000, origin = "1970-01-01"),
    tanggal = as.Date(tanggal)
  )
#melihat tipe data
str(new_cov_jabar) 
## 'data.frame':    785 obs. of  4 variables:
##  $ tanggal   : Date, format: "2020-03-03" "2020-03-04" ...
##  $ kasus_baru: int  1 1 1 1 0 0 0 0 0 1 ...
##  $ meninggal : int  1 0 0 0 0 0 0 0 1 0 ...
##  $ sembuh    : int  0 0 0 0 0 0 0 0 0 0 ...

View the Graph

#set library yang dibutuhkan
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.2
#membuat bar chart
library(hrbrthemes)
## Warning: package 'hrbrthemes' was built under R version 4.2.2
## 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
ggplot(data = new_cov_jabar, aes(x = tanggal, y = kasus_baru)) +
  geom_col()

View the Graph - Pt 2

#set library yang dibutuhkan
library(ggplot2)
library(hrbrthemes)
#membuat bar chart modifikasi
ggplot(new_cov_jabar, aes(tanggal, kasus_baru)) +
    geom_col(fill = "salmon") +
labs(
    x = NULL,
    y = "Jumlah kasus",
    title = "Kasus Harian Positif COVID-19 di Jawa Barat",
    subtitle = "Terjadi pelonjakan kasus di awal bulan Juli akibat klaster Secapa AD Bandung",
    caption = "Sumber data: covid.19.go.id"
  ) +
  theme_ipsum(
    base_size = 13,
    plot_title_size = 21,
    grid = "Y",
    ticks = TRUE
  ) +
  theme(plot.title.position = "plot")
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## The graph of recovered cases

library(ggplot2)
library(hrbrthemes)

#membuat bar chart kasus sembuh
ggplot(new_cov_jabar, aes(tanggal, sembuh)) +
  geom_col(fill = "olivedrab2") +
  labs(
    x = NULL,
    y = "Jumlah kasus",
    title = "Kasus Harian Sembuh Dari COVID-19 di Jawa Barat",
    caption = "Sumber data: covid.19.go.id"
  ) +
  theme_ipsum(
    base_size = 13, 
    plot_title_size = 21,
    grid = "Y",
    ticks = TRUE
  ) +
  theme(plot.title.position = "plot")
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

The graph of death cases

library(ggplot2)
library(hrbrthemes)
ggplot(new_cov_jabar, aes(tanggal, meninggal)) +
  geom_col(fill = "darkslategray4") +
  labs(
    x = NULL,
    y = "Jumlah kasus",
    title = "Kasus Harian Meninggal Akibat COVID-19 di Jawa Barat",
    caption = "Sumber data: covid.19.go.id"
  ) +
  theme_ipsum(
    base_size = 13, 
    plot_title_size = 21,
    grid = "Y",
    ticks = TRUE
  ) +
  theme(plot.title.position = "plot")
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

Is this week better?

library(dplyr)
library(lubridate)
## Warning: package 'lubridate' was built under R version 4.2.2
## Loading required package: timechange
## Warning: package 'timechange' was built under R version 4.2.2
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
#membuat variabel dataset
cov_jabar_pekanan <- new_cov_jabar %>% 
  count(
    tahun = year(tanggal),
    pekan_ke = week(tanggal),
    wt = kasus_baru,
    name = "jumlah"
  )
#melakukan inspeksi data
glimpse(cov_jabar_pekanan)
## Rows: 115
## Columns: 3
## $ tahun    <dbl> 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2…
## $ pekan_ke <dbl> 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24…
## $ jumlah   <int> 1, 3, 16, 41, 98, 149, 153, 155, 156, 284, 803, 175, 395, 203…

Answering questions

#set library yang dibutuhkan
library(dplyr)
#membuat variabel dataset
cov_jabar_pekanan <-
  cov_jabar_pekanan %>% 
  mutate(
    jumlah_pekanlalu = dplyr::lag(jumlah, 1),
    jumlah_pekanlalu = ifelse(is.na(jumlah_pekanlalu), 0, jumlah_pekanlalu),
    lebih_baik = jumlah < jumlah_pekanlalu
  )
#melakukan inspeksi data
glimpse(cov_jabar_pekanan)
## Rows: 115
## Columns: 5
## $ tahun            <dbl> 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020,…
## $ pekan_ke         <dbl> 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22…
## $ jumlah           <int> 1, 3, 16, 41, 98, 149, 153, 155, 156, 284, 803, 175, …
## $ jumlah_pekanlalu <dbl> 0, 1, 3, 16, 41, 98, 149, 153, 155, 156, 284, 803, 17…
## $ lebih_baik       <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALS…

Make out Bar Chart

library(dplyr)
cov_jabar_akumulasi <- 
  new_cov_jabar %>% 
  transmute(
    tanggal,
    akumulasi_aktif = cumsum(kasus_baru) - cumsum(sembuh) - cumsum(meninggal),
    akumulasi_sembuh = cumsum(sembuh),
    akumulasi_meninggal = cumsum(meninggal)
  )

tail(cov_jabar_akumulasi)
##        tanggal akumulasi_aktif akumulasi_sembuh akumulasi_meninggal
## 780 2022-04-21           11628          1077361               15731
## 781 2022-04-22           10753          1078344               15735
## 782 2022-04-23            9882          1079297               15737
## 783 2022-04-24            8709          1080519               15748
## 784 2022-04-25            5428          1083851               15751
## 785 2022-04-26            3253          1086129               15752
library(ggplot2)
library(hrbrthemes)

ggplot(cov_jabar_pekanan[cov_jabar_pekanan$tahun==2020,], aes(pekan_ke, jumlah, fill =lebih_baik)) +
 geom_col(show.legend = FALSE) +
 scale_x_continuous(breaks = 9:29, expand = c(0,0)) +
 scale_fill_manual(values = c("TRUE" = "seagreen3", "FALSE" = "salmon")) +
 labs(
   x = NULL,
   y = "Jumlah kasus",
   title = "Kasus Pekanan Positif COVID-19 di Jawa Barat",
   subtitle = "Kolom hijau menunjukan penambahan kasus baru lebih sedikit dibandingkan satu pekan sebelumnya",
   caption = "Sumber data: covid.19.go.id"
 ) +
  theme_ipsum(
  base_size = 13,
  plot_title_size = 21,
  grid = "Y",
  ticks = TRUE
  ) +
theme(plot.title.position = "plot")
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

##Patterns and dynamics

library(dplyr)
cov_jabar_akumulasi <- 
  new_cov_jabar %>% 
  transmute(
    tanggal,
    akumulasi_aktif = cumsum(kasus_baru) - cumsum(sembuh) - cumsum(meninggal),
    akumulasi_sembuh = cumsum(sembuh),
    akumulasi_meninggal = cumsum(meninggal)
  )

tail(cov_jabar_akumulasi)
##        tanggal akumulasi_aktif akumulasi_sembuh akumulasi_meninggal
## 780 2022-04-21           11628          1077361               15731
## 781 2022-04-22           10753          1078344               15735
## 782 2022-04-23            9882          1079297               15737
## 783 2022-04-24            8709          1080519               15748
## 784 2022-04-25            5428          1083851               15751
## 785 2022-04-26            3253          1086129               15752

Make Line chart

library(ggplot2)
ggplot(data = cov_jabar_akumulasi, aes(x = tanggal, y = akumulasi_aktif)) +
  geom_line()

Transformation Data

library(dplyr)
library(tidyr)
## Warning: package 'tidyr' was built under R version 4.2.2
dim(cov_jabar_akumulasi)
## [1] 785   4
cov_jabar_akumulasi_pivot <- 
  cov_jabar_akumulasi %>% 
  gather(
    key = "kategori",
    value = "jumlah",
    -tanggal
  ) %>% 
  mutate(
    kategori = sub(pattern = "akumulasi_", replacement = "", kategori)
  )

dim(cov_jabar_akumulasi_pivot)
## [1] 2355    3
glimpse(cov_jabar_akumulasi_pivot)
## Rows: 2,355
## Columns: 3
## $ tanggal  <date> 2020-03-03, 2020-03-04, 2020-03-05, 2020-03-06, 2020-03-07, …
## $ kategori <chr> "aktif", "aktif", "aktif", "aktif", "aktif", "aktif", "aktif"…
## $ jumlah   <int> 0, 1, 2, 3, 3, 3, 3, 3, 2, 3, 6, 6, 4, 2, 13, 14, 17, 29, 34,…

Finally

library(ggplot2)
library(hrbrthemes)
#membuat grafik komparasi
ggplot(cov_jabar_akumulasi_pivot, aes(tanggal, jumlah, colour = (kategori))) +
  geom_line(size = 0.9) +
  scale_y_continuous(sec.axis = dup_axis(name = NULL)) +
  scale_colour_manual(
    values = c(
      "aktif" = "salmon",
      "meninggal" = "darkslategray4",
      "sembuh" = "olivedrab2"
    ),
    labels = c("Aktif", "Meninggal", "Sembuh")
  ) +
  labs(
    x = NULL,
    y = "Jumlah kasus akumulasi",
    colour = NULL,
    title = "Dinamika kasus COVID-19 di Jawa Barat",
    caption = "Sumber data: covid.19.go.id"
  ) +
  theme_ipsum(
    base_size = 13,
    plot_title_size = 21,
    grid = "Y",
    ticks = TRUE
  ) +
  theme(
    plot.title = element_text(hjust = 0.5),
    legend.position = "top"
  )
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database