library(ggplot2) # membuat plot statis
library(ggpubr) # export plot statis
library(scales) # mengatur skala plot
library(glue) # setting teks pada tooltip
library(plotly) # membuat plot interaktif
library(dplyr)
library(lubridate)
library(flexdashboard)
library(tidyverse)
library(plotly)
library(leaflet)
library(leafgl)
library(sf)
library(colourvalues)
library(highcharter)
library(chron)
library(viridis)
library(shiny)
library(DT)#Introduction
Indonesia is an Archipelago country which is crossed by many of the earth’s tectonic plates. Those tectonic plates potentially raises earthquakes caused by the movement of tectonic plates which is happened everyday. But, not all those earthquakes could be felt by human due to its magnitudes, central location, and depth of the earthquakes from human settlement.
World’s three main tectonic plates crossed Indonesia, it is Indo-Australia, Pacific, and Eurasia.
knitr::include_graphics("peta tektonik indonesia.jpg")earthquakes <- read.csv("katalog_gempa.csv")
earthquakes2 <- earthquakes %>%
select(-c(8:13)) %>%
mutate(ot = as.factor(ot)) %>%
mutate(tgl = mdy(tgl)) %>%
mutate(remark = as.factor(remark)) %>%
mutate(label = glue(
"Magnitude: {mag}
Region: {remark}"
)) %>%
mutate(label2 = glue(
"Depth: {depth}
Region: {remark}"
)) %>%
arrange(-mag)
earthquakes2earthquakes2 %>% is.na() %>% colSums()#> tgl ot lat lon depth mag remark label label2
#> 0 0 0 0 0 0 0 0 0
#Plot 1 ## Scatter Plot of Magnitude
plot(x = earthquakes2$mag, y = earthquakes2$tgl,
col = earthquakes2$remark,
pch = 19
)
abline(lm(earthquakes2$tgl ~ earthquakes2$mag))
###Insight : Most of the earthquake magnitude occured in 2008-2023 is
ranging bigger than 2 and smaller than 6
#Plot 2 ## Bar Plot of Magnitude
plot2 <- ggplot(data = earthquakes2,
aes(x = mag,
y = reorder(remark, mag),
text = label )) +
geom_col(aes(fill = mag )) +
scale_fill_gradient(low = "blue", high = "green") +
labs(title = "Earthquakes in Indonesia 2008-2023",
x = "Frequency of Earthquakes",
y = NULL) +
theme_minimal()
ggplotly (plot2, tooltip = "text") ###Insight : Most top 3 frequent region got earthquake is Sumatra, Java, and Minahasa Peninsula
#Plot 3 ## Scatter Plot of Depth
plot(x = earthquakes2$depth, y = earthquakes2$tgl,
col = earthquakes2$remark,
pch = 19
)
abline(lm(earthquakes2$tgl ~ earthquakes2$depth))
###Insight : Most earthquake were occured at the depth between 2 km
until 200 km under the ground
#Interactive Map
map <- leaflet()
map <- addTiles(map)
map <-
addCircleMarkers(
lat = earthquakes2$lat,
lng = earthquakes2$lon,
map = map,
weight = 0.1,
radius = sqrt(earthquakes2$mag),
opacity = 0.7,
color = palette(),
popup = paste("Depth: ", earthquakes2$depth, "Magnitude: ", earthquakes2$mag, "Region: ", earthquakes2$remark))
map