Visualisasi animasi Google Mobility Index Indonesia dengan gganimate |
Perkembangan Big Data demikian pesat. Data tidak terstruktur dan terstruktur bercampur menjadi sebuah awan data yang berdimensi besar, memiliki kecepatan update yang tinggi, bervariasi, serta mengandung value serta insight berharga apabila dikupas secara mendalam.
Penggunaan Big Data juga sangat diminati akhir-akhir ini seiring kehadiran cabang-cabang ilmu baru, seperti Data Science. Meski masih untrusted dan debatable karena belum ada payung hukum yang menjamin potensi Big Data menjadi Official Statistics, tetapi kenyataan empiris yang berkembang menyebutkan bahwa Big Data berpotensi menjadi sumber data Official Statistics baru.
Salah satu Big Data yang lahir di tengah masa Pandemi Covid-19 adalah data mobilitas penduduk yang diukur berdasarkan base mobilitas awal kedatangan Pandemi Covid-19. Data ini dibuat oleh Google dalam bentuk indeks dan dinamai Google Mobility Index (GMI). Sekilas, indeks ini menunjukkan tingkat mobilitas masyarakat ke beberapa tempat tujuan aktivitas, yaitu ke pasar, tempat rekreasi, toko obat, taman, tempat transit, tempat kerja, dan residential.
Pada kesempatan kali ini, kita akan mencoba mempratikkan visualisasi Google Mobility Index Indonesia menggunakan package gganimate. Keunggulan dari package gganimate adalah mampu membuat tampilan data yang dinamis karena memiliki fungsi render setiap gambar yang terbentuk (frame) menjadi sebuah visualisasi bergerak (animasi). Selain kita dapat mengatur jumlah frame, kita juga bisa mengcustome ukuran visualisasi, kecepatan gerakan, serta ketajaman visualisasi. Adapun cara melakukan interpretasi terhadap GMI dapat melihat laman berikut.
Data yang kita gunakan dalam praktik kali mencakup data Google Mobility Index (GMI) untuk wilayah Indonesia sejak 15 Februari 2020 hingga 15 Oktober 2022 berikut. Setelah datanya diunduh, praktik visualisasi menggunakan package gganimate kita terapkan dengan mengikuti langkah-langkah berikut:
library(readxl)
indo_1 <- read_excel("C:/Users/Joko Ade/Documents/gmi_id2023.xlsx")
head(indo_1)
## # A tibble: 6 x 8
## date retail_recreation grocery_pharmacy parks transit_stations
## <dttm> <dbl> <dbl> <dbl> <dbl>
## 1 2020-02-15 00:00:00 -2 -2 -8 1
## 2 2020-02-16 00:00:00 -3 -3 -7 -4
## 3 2020-02-17 00:00:00 -3 -4 -7 -1
## 4 2020-02-18 00:00:00 -3 -2 -4 1
## 5 2020-02-19 00:00:00 -3 -4 -3 0
## 6 2020-02-20 00:00:00 -2 -1 -1 4
## # ... with 3 more variables: workplaces <dbl>, residential <dbl>, waktu <dttm>
#Melihat variabel data Google Mobility Index Indonesia
names(indo_1)
## [1] "date" "retail_recreation" "grocery_pharmacy" "parks"
## [5] "transit_stations" "workplaces" "residential" "waktu"
#Visualisasi dengan ggplot2
library(ggplot2)
indo_1 %>%
ggplot(aes(x = waktu)) +
geom_line(aes(y = retail_recreation), col = "red") +
geom_line(aes(y = grocery_pharmacy), col = "orange") +
geom_line(aes(y = workplaces), col = "green") +
geom_point(aes(y = retail_recreation), col = "red") +
geom_point(aes(y = grocery_pharmacy), col = "orange") +
geom_point(aes(y = workplaces), col = "green") +
geom_vline(xintercept = as.numeric(ymd("2020-04-02")), linetype = "dotted", size = 0.8, color = "blue") +
geom_text(x = as.numeric(ymd("2020-03-20")), y = 40, label = "PSBB DKI Jakarta", size = 3, angle = 90) +
geom_vline(xintercept = as.numeric(ymd("2020-04-10")), linetype = "dotted", size = 0.8, color = "blue") +
geom_text(x = as.numeric(ymd("2020-04-20")), y = 40, label = "PSBB Beberapa Wilayah", size = 3, angle = 90) +
geom_vline(xintercept = as.numeric(ymd("2020-06-05")), linetype = "dotted", size = 0.8, color = "blue") +
geom_text(x = as.numeric(ymd("2020-05-20")), y = 40, label = "Pelonggaran PSBB", size = 3, angle = 90) +
geom_vline(xintercept = as.numeric(ymd("2020-09-14")), linetype = "dotted", size = 0.8, color = "blue") +
geom_text(x = as.numeric(ymd("2020-09-04")), y = 40, label = "PSBB DKI Jakarta", size = 3, angle = 90) +
geom_vline(xintercept = as.numeric(ymd("2021-01-26")), linetype = "dotted", size = 0.8, color = "blue") +
geom_text(x = as.numeric(ymd("2021-01-20")), y = 40, label = "PPKM Jawa Bali", size = 3, angle = 90) +
geom_vline(xintercept = as.numeric(ymd("2021-02-09")), linetype = "dotted", size = 0.8, color = "blue") +
geom_text(x = as.numeric(ymd("2021-01-30")), y = 40, label = "PPKM Mikro", size = 3, angle = 90) +
geom_vline(xintercept = as.numeric(ymd("2021-07-03")), linetype = "dotted", size = 0.8, color = "blue") +
geom_text(x = as.numeric(ymd("2021-06-25")), y = 40, label = "PPKM Darurat", size = 3, angle = 90) +
geom_vline(xintercept = as.numeric(ymd("2021-07-15")), linetype = "dotted", size = 0.8, color = "blue") +
geom_text(x = as.numeric(ymd("2021-07-06")), y = 40, label = "Covid19 Delta", size = 3, angle = 90) +
geom_vline(xintercept = as.numeric(ymd("2022-05-18")), linetype = "dotted", size = 0.8, color = "blue") +
geom_text(x = as.numeric(ymd("2022-05-1")), y = 60, label = "Pelonggaran pakai masker", size = 3) +
ylim(-75, 60) +
labs(x = "periode", y = "indeks mobilitas") -> p
#Animasi ggplot dengan gganimate
library(gganimate)
p +
labs(x = "periode", y = "Indeks Mobilitas") +
transition_reveal(waktu) -> q
animate(q, nframe = 800, end_pause = 20,
width = 800, height = 600, duration = 20, res = 100)
## Rendering [-------------------------------------------------] at 8.4 fps ~ eta: 2m
## Rendering [-------------------------------------------------] at 7.6 fps ~ eta: 2m
## Rendering [-------------------------------------------------] at 5.8 fps ~ eta: 2m
## Rendering [-------------------------------------------------] at 5.9 fps ~ eta: 2m
## Rendering [-------------------------------------------------] at 6.3 fps ~ eta: 2m
## Rendering [-------------------------------------------------] at 6.7 fps ~ eta: 2m
## Rendering [>--------------------------------------------------] at 7 fps ~ eta: 2m
## Rendering [>------------------------------------------------] at 7.3 fps ~ eta: 2m
## Rendering [>------------------------------------------------] at 7.5 fps ~ eta: 2m
## Rendering [>------------------------------------------------] at 7.7 fps ~ eta: 2m
## Rendering [>------------------------------------------------] at 7.9 fps ~ eta: 2m
## Rendering [>--------------------------------------------------] at 8 fps ~ eta: 2m
## Rendering [>------------------------------------------------] at 8.1 fps ~ eta: 2m
## Rendering [>------------------------------------------------] at 8.2 fps ~ eta: 2m
## Rendering [>------------------------------------------------] at 8.3 fps ~ eta: 2m
## Rendering [>------------------------------------------------] at 8.5 fps ~ eta: 1m
## Rendering [>------------------------------------------------] at 8.6 fps ~ eta: 1m
## Rendering [>------------------------------------------------] at 8.4 fps ~ eta: 1m
## Rendering [=>-----------------------------------------------] at 8.4 fps ~ eta: 1m
## Rendering [=>-----------------------------------------------] at 8.5 fps ~ eta: 1m
## Rendering [=>-----------------------------------------------] at 8.6 fps ~ eta: 1m
## Rendering [=>-----------------------------------------------] at 8.7 fps ~ eta: 1m
## Rendering [=>-----------------------------------------------] at 8.6 fps ~ eta: 1m
## Rendering [=>-----------------------------------------------] at 8.7 fps ~ eta: 1m
## Rendering [=>-----------------------------------------------] at 8.8 fps ~ eta: 1m
## Rendering [=>-----------------------------------------------] at 8.7 fps ~ eta: 1m
## Rendering [=>-----------------------------------------------] at 8.8 fps ~ eta: 1m
## Rendering [==>----------------------------------------------] at 8.6 fps ~ eta: 1m
## Rendering [==>----------------------------------------------] at 8.3 fps ~ eta: 1m
## Rendering [==>----------------------------------------------] at 8.2 fps ~ eta: 2m
## Rendering [==>----------------------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [==>------------------------------------------------] at 8 fps ~ eta: 2m
## Rendering [==>----------------------------------------------] at 7.9 fps ~ eta: 2m
## Rendering [==>----------------------------------------------] at 7.8 fps ~ eta: 2m
## Rendering [===>---------------------------------------------] at 7.9 fps ~ eta: 2m
## Rendering [===>-----------------------------------------------] at 8 fps ~ eta: 2m
## Rendering [===>-----------------------------------------------] at 8 fps ~ eta: 1m
## Rendering [===>---------------------------------------------] at 8.1 fps ~ eta: 1m
## Rendering [===>-----------------------------------------------] at 8 fps ~ eta: 1m
## Rendering [===>---------------------------------------------] at 8.1 fps ~ eta: 1m
## Rendering [===>---------------------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [===>---------------------------------------------] at 7.2 fps ~ eta: 2m
## Rendering [===>---------------------------------------------] at 7.3 fps ~ eta: 2m
## Rendering [====>--------------------------------------------] at 7.3 fps ~ eta: 2m
## Rendering [====>--------------------------------------------] at 7.4 fps ~ eta: 2m
## Rendering [====>--------------------------------------------] at 7.5 fps ~ eta: 2m
## Rendering [====>--------------------------------------------] at 7.6 fps ~ eta: 2m
## Rendering [=====>-------------------------------------------] at 7.6 fps ~ eta: 2m
## Rendering [=====>-------------------------------------------] at 7.7 fps ~ eta: 2m
## Rendering [=====>-------------------------------------------] at 7.7 fps ~ eta: 1m
## Rendering [=====>-------------------------------------------] at 7.8 fps ~ eta: 1m
## Rendering [=====>-------------------------------------------] at 7.9 fps ~ eta: 1m
## Rendering [======>------------------------------------------] at 7.8 fps ~ eta: 1m
## Rendering [======>------------------------------------------] at 7.9 fps ~ eta: 1m
## Rendering [=======>-----------------------------------------] at 7.9 fps ~ eta: 1m
## Rendering [=======>-------------------------------------------] at 8 fps ~ eta: 1m
## Rendering [========>------------------------------------------] at 8 fps ~ eta: 1m
## Rendering [========>----------------------------------------] at 8.1 fps ~ eta: 1m
## Rendering [=========>---------------------------------------] at 8.1 fps ~ eta: 1m
## Rendering [==========>--------------------------------------] at 8.1 fps ~ eta: 1m
## Rendering [==========>--------------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [===========>-------------------------------------] at 8.1 fps ~ eta: 1m
## Rendering [============>------------------------------------] at 8.1 fps ~ eta: 1m
## Rendering [============>------------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [============>------------------------------------] at 8.1 fps ~ eta: 1m
## Rendering [============>------------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [=============>-----------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [==============>----------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [==============>----------------------------------] at 8.3 fps ~ eta: 1m
## Rendering [==============>----------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [==============>----------------------------------] at 8.3 fps ~ eta: 1m
## Rendering [===============>---------------------------------] at 8.3 fps ~ eta: 1m
## Rendering [===============>---------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [================>--------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [================>--------------------------------] at 8.3 fps ~ eta: 1m
## Rendering [================>--------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [=================>-------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [=================>-------------------------------] at 8.3 fps ~ eta: 1m
## Rendering [=================>-------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [=================>-------------------------------] at 8.3 fps ~ eta: 1m
## Rendering [=================>-------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [=================>-------------------------------] at 8.3 fps ~ eta: 1m
## Rendering [==================>------------------------------] at 8.3 fps ~ eta: 1m
## Rendering [==================>------------------------------] at 8.2 fps ~ eta: 1m
## Rendering [===================>-----------------------------] at 8.2 fps ~ eta: 1m
## Rendering [===================>-----------------------------] at 8.1 fps ~ eta: 1m
## Rendering [====================>----------------------------] at 8.1 fps ~ eta: 1m
## Rendering [=====================>---------------------------] at 8.1 fps ~ eta: 1m
## Rendering [======================>----------------------------] at 8 fps ~ eta: 1m
## Rendering [=====================>---------------------------] at 8.1 fps ~ eta: 1m
## Rendering [======================>----------------------------] at 8 fps ~ eta: 1m
## Rendering [=======================>---------------------------] at 8 fps ~ eta: 1m
## Rendering [========================>--------------------------] at 8 fps ~ eta: 1m Rendering
## [========================>--------------------------] at 8 fps ~ eta: 50s Rendering
## [========================>--------------------------] at 8 fps ~ eta: 49s Rendering
## [=======================>-------------------------] at 7.9 fps ~ eta: 49s Rendering
## [========================>------------------------] at 7.9 fps ~ eta: 49s Rendering
## [========================>------------------------] at 7.9 fps ~ eta: 48s Rendering
## [========================>------------------------] at 7.9 fps ~ eta: 47s Rendering
## [=========================>-----------------------] at 7.9 fps ~ eta: 47s Rendering
## [=========================>-----------------------] at 7.9 fps ~ eta: 46s Rendering
## [=========================>-----------------------] at 7.9 fps ~ eta: 45s Rendering
## [==========================>----------------------] at 7.9 fps ~ eta: 45s Rendering
## [==========================>----------------------] at 7.9 fps ~ eta: 44s Rendering
## [===========================>---------------------] at 7.9 fps ~ eta: 44s Rendering
## [===========================>---------------------] at 7.9 fps ~ eta: 43s Rendering
## [===========================>---------------------] at 7.8 fps ~ eta: 43s Rendering
## [===========================>---------------------] at 7.8 fps ~ eta: 42s Rendering
## [============================>--------------------] at 7.8 fps ~ eta: 42s Rendering
## [============================>--------------------] at 7.8 fps ~ eta: 41s Rendering
## [============================>--------------------] at 7.8 fps ~ eta: 40s Rendering
## [=============================>-------------------] at 7.8 fps ~ eta: 40s Rendering
## [=============================>-------------------] at 7.8 fps ~ eta: 39s Rendering
## [=============================>-------------------] at 7.8 fps ~ eta: 38s Rendering
## [==============================>------------------] at 7.8 fps ~ eta: 38s Rendering
## [==============================>------------------] at 7.8 fps ~ eta: 37s Rendering
## [==============================>------------------] at 7.8 fps ~ eta: 36s Rendering
## [===============================>-----------------] at 7.8 fps ~ eta: 36s Rendering
## [===============================>-----------------] at 7.8 fps ~ eta: 35s Rendering
## [===============================>-----------------] at 7.8 fps ~ eta: 34s Rendering
## [================================>----------------] at 7.8 fps ~ eta: 34s Rendering
## [================================>----------------] at 7.8 fps ~ eta: 33s Rendering
## [================================>----------------] at 7.8 fps ~ eta: 32s Rendering
## [=================================>---------------] at 7.8 fps ~ eta: 32s Rendering
## [=================================>---------------] at 7.8 fps ~ eta: 31s Rendering
## [=================================>---------------] at 7.8 fps ~ eta: 30s Rendering
## [==================================>--------------] at 7.8 fps ~ eta: 30s Rendering
## [==================================>--------------] at 7.8 fps ~ eta: 29s Rendering
## [==================================>--------------] at 7.8 fps ~ eta: 28s Rendering
## [==================================>--------------] at 7.7 fps ~ eta: 28s Rendering
## [==================================>--------------] at 7.8 fps ~ eta: 28s Rendering
## [===================================>-------------] at 7.7 fps ~ eta: 28s Rendering
## [===================================>-------------] at 7.7 fps ~ eta: 27s Rendering
## [===================================>-------------] at 7.8 fps ~ eta: 27s Rendering
## [===================================>-------------] at 7.7 fps ~ eta: 27s Rendering
## [===================================>-------------] at 7.7 fps ~ eta: 26s Rendering
## [====================================>------------] at 7.7 fps ~ eta: 26s Rendering
## [====================================>------------] at 7.7 fps ~ eta: 25s Rendering
## [====================================>------------] at 7.7 fps ~ eta: 24s Rendering
## [====================================>------------] at 7.6 fps ~ eta: 25s Rendering
## [====================================>------------] at 7.6 fps ~ eta: 24s Rendering
## [=====================================>-----------] at 7.6 fps ~ eta: 24s Rendering
## [=====================================>-----------] at 7.6 fps ~ eta: 23s Rendering
## [=====================================>-----------] at 7.6 fps ~ eta: 22s Rendering
## [======================================>----------] at 7.6 fps ~ eta: 22s Rendering
## [======================================>----------] at 7.6 fps ~ eta: 21s Rendering
## [======================================>----------] at 7.6 fps ~ eta: 20s Rendering
## [=======================================>---------] at 7.6 fps ~ eta: 20s Rendering
## [=======================================>---------] at 7.6 fps ~ eta: 19s Rendering
## [=======================================>---------] at 7.6 fps ~ eta: 18s
## Warning: Removed 1 row(s) containing missing values (geom_path).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 2 row(s) containing missing values (geom_path).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 4 row(s) containing missing values (geom_path).
## Warning: Removed 1 rows containing missing values (geom_point).
## Rendering [========================================>--------] at 7.6 fps ~ eta: 18s
## Warning: Removed 5 row(s) containing missing values (geom_path).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 1 row(s) containing missing values (geom_path).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 2 row(s) containing missing values (geom_path).
## Warning: Removed 1 rows containing missing values (geom_point).
## Rendering [========================================>--------] at 7.6 fps ~ eta: 17s
## Warning: Removed 4 row(s) containing missing values (geom_path).
## Warning: Removed 1 rows containing missing values (geom_point).
##
Rendering [========================================>--------] at 7.6 fps ~ eta: 16s
Rendering [=========================================>-------] at 7.6 fps ~ eta: 16s
Rendering [=========================================>-------] at 7.6 fps ~ eta: 15s
Rendering [=========================================>-------] at 7.6 fps ~ eta: 14s
Rendering [=========================================>-------] at 7.5 fps ~ eta: 14s
Rendering [==========================================>------] at 7.5 fps ~ eta: 14s
Rendering [==========================================>------] at 7.5 fps ~ eta: 13s
Rendering [==========================================>------] at 7.5 fps ~ eta: 12s
Rendering [==========================================>------] at 7.4 fps ~ eta: 12s
Rendering [===========================================>-----] at 7.4 fps ~ eta: 12s
Rendering [===========================================>-----] at 7.4 fps ~ eta: 11s
Rendering [===========================================>-----] at 7.4 fps ~ eta: 10s
Rendering [============================================>----] at 7.4 fps ~ eta: 10s
Rendering [============================================>----] at 7.4 fps ~ eta: 9s
Rendering [============================================>----] at 7.3 fps ~ eta: 8s
Rendering [=============================================>---] at 7.3 fps ~ eta: 8s
Rendering [=============================================>---] at 7.3 fps ~ eta: 7s
Rendering [=============================================>---] at 7.3 fps ~ eta: 6s
Rendering [=============================================>---] at 7.2 fps ~ eta: 6s
Rendering [===============================================>---] at 7 fps ~ eta: 6s
Rendering [=============================================>---] at 6.9 fps ~ eta: 6s
Rendering [==============================================>--] at 6.8 fps ~ eta: 6s
Rendering [==============================================>--] at 6.6 fps ~ eta: 6s
Rendering [==============================================>--] at 6.5 fps ~ eta: 6s
Rendering [==============================================>--] at 6.4 fps ~ eta: 5s
Rendering [==============================================>--] at 6.3 fps ~ eta: 5s
Rendering [==============================================>--] at 6.3 fps ~ eta: 4s
Rendering [===============================================>-] at 6.3 fps ~ eta: 4s
Rendering [===============================================>-] at 6.3 fps ~ eta: 3s
Rendering [===============================================>-] at 6.2 fps ~ eta: 3s
Rendering [===============================================>-] at 5.9 fps ~ eta: 3s
Rendering [===============================================>-] at 5.9 fps ~ eta: 2s
Rendering [===============================================>-] at 5.7 fps ~ eta: 2s
Rendering [===============================================>-] at 5.6 fps ~ eta: 1s
Rendering [================================================>] at 5.3 fps ~ eta: 1s
Rendering [================================================>] at 5.2 fps ~ eta: 1s
Rendering [================================================>] at 5.1 fps ~ eta: 0s
Rendering [=================================================] at 5.1 fps ~ eta: 0s
Adapun hasilnya adalah sebagai berikut:
Visualisasi menggunakan package gganimate |
Demikian sedikit sharing kita kali ini. Semoga sedikit banyak memberi manfaat kepada pembaca blog ini. Jangan lupa untuk terus mengikuti unggahan menarik dan bermanfaat di blog sederhana ini. Selamat membaca dan mempraktikan!