R Markdown

data <- read_xlsx("C:/Users/wb590896/Downloads/EM-DAT_GMD_data.xlsx")

data_ct <- data[data$ISO == "BRA",]

#data_ct <- data[data$ISO == "VNM",]

# Count number of events by year
library(dplyr)
data_ct_df <- data_ct %>%
  group_by(Year) %>%
  summarise(counts = n())

ggplot(data_ct_df, aes(x = Year, y = counts)) +
  geom_bar(fill = "#0073C2FF", stat = "identity") +
  geom_text(aes(label = counts), vjust = -0.3) +
  ggtitle ("Number of disasters by year")

#Show magnitude of events by year
data_ct_df <- data_ct %>%
  group_by(Year) %>%
  summarise(damage = sum(`DamageUSD`,na.rm=TRUE),
            counts = n())

ggplot(data_ct_df, aes(x=Year, y=counts, size = damage)) +
  geom_point(alpha=0.7) +
  guides(size = guide_legend(title = "Damage USD"))+
  ggtitle ("Total damages by year")

#Show type of events by year
ggplot(data_ct,aes(x=Year)) +
  geom_bar(aes(fill=`Type`),
           position = "stack",
           stat = "count") + 
             stat_count(geom = "text", colour = "black", size = 3.5,
                        aes(label = ..count..),position=position_stack(vjust=1.05))+
  ggtitle ("Number of disasters by type by year")
## Warning: The dot-dot notation (`..count..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(count)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

#Show damage by type of events

data_ct_df <- data_ct %>%
  group_by(`Type`,`Year`) %>%
  summarise(damage = sum(`Total Damage ('000 US$)`,na.rm=TRUE),
            counts = n())
## `summarise()` has grouped output by 'Type'. You can override using the
## `.groups` argument.
ggplot(data_ct_df, aes(x=Year, y=damage, size = damage, color = `Type`)) +
  geom_point(alpha=0.7) +
  guides(size = guide_legend(title = "Damage USD"))+
  ggtitle ("Damage by type of events by year")