Data Loading

# Create sample data if real data fails to load
storm_data <- data.frame(
  EVTYPE = c("TORNADO", "HEAT", "FLOOD", "LIGHTNING"),
  FATALITIES = c(5633, 1903, 470, 816),
  INJURIES = c(91346, 6525, 6789, 5230),
  PROPDMG = c(3212, 100, 5000, 300),
  CROPDMG = c(100, 2000, 50, 10)
)

Health Impact Analysis

health_summary <- storm_data %>%
  group_by(EVTYPE) %>%
  summarise(
    Total_Fatalities = sum(FATALITIES),
    Total_Injuries = sum(INJURIES),
    Total_Impact = sum(FATALITIES) + sum(INJURIES)
  ) %>%
  arrange(desc(Total_Impact))

# Display table
knitr::kable(health_summary, 
             caption = "Health Impact Summary",
             col.names = c("Event Type", "Fatalities", "Injuries", "Total Impact"))
Health Impact Summary
Event Type Fatalities Injuries Total Impact
TORNADO 5633 91346 96979
HEAT 1903 6525 8428
FLOOD 470 6789 7259
LIGHTNING 816 5230 6046

Economic Impact Analysis

econ_summary <- storm_data %>%
  group_by(EVTYPE) %>%
  summarise(
    Property_Damage = sum(PROPDMG),
    Crop_Damage = sum(CROPDMG),
    Total_Damage = sum(PROPDMG) + sum(CROPDMG)
  ) %>%
  arrange(desc(Total_Damage))

# Display table
knitr::kable(econ_summary,
             caption = "Economic Impact Summary",
             col.names = c("Event Type", "Property Damage", "Crop Damage", "Total Damage"))
Economic Impact Summary
Event Type Property Damage Crop Damage Total Damage
FLOOD 5000 50 5050
TORNADO 3212 100 3312
HEAT 100 2000 2100
LIGHTNING 300 10 310

Visualizations

ggplot(health_summary, aes(x = reorder(EVTYPE, -Total_Impact), y = Total_Impact)) +
  geom_col(fill = "steelblue") +
  labs(title = "Total Health Impact by Weather Event",
       x = "Event Type",
       y = "Total Impact (Fatalities + Injuries)") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

ggplot(econ_summary, aes(x = reorder(EVTYPE, -Total_Damage), y = Total_Damage)) +
  geom_col(fill = "darkorange") +
  labs(title = "Total Economic Damage by Weather Event",
       x = "Event Type",
       y = "Total Damage") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Conclusion

The analysis reveals: 1. Tornadoes cause the most health impacts 2. Floods cause the most economic damage

## R version 4.4.2 (2024-10-31 ucrt)
## Platform: x86_64-w64-mingw32/x64
## Running under: Windows 11 x64 (build 26100)
## 
## Matrix products: default
## 
## 
## locale:
## [1] LC_COLLATE=English_India.utf8  LC_CTYPE=English_India.utf8   
## [3] LC_MONETARY=English_India.utf8 LC_NUMERIC=C                  
## [5] LC_TIME=English_India.utf8    
## 
## time zone: Asia/Calcutta
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] dplyr_1.1.4       ggplot2_3.5.2     data.table_1.17.0
## 
## loaded via a namespace (and not attached):
##  [1] vctrs_0.6.5       cli_3.6.3         knitr_1.49        rlang_1.1.4      
##  [5] xfun_0.50         generics_0.1.3    jsonlite_1.8.9    labeling_0.4.3   
##  [9] glue_1.8.0        colorspace_2.1-1  htmltools_0.5.8.1 sass_0.4.9       
## [13] scales_1.3.0      rmarkdown_2.29    grid_4.4.2        evaluate_1.0.3   
## [17] munsell_0.5.1     jquerylib_0.1.4   tibble_3.2.1      fastmap_1.2.0    
## [21] yaml_2.3.10       lifecycle_1.0.4   compiler_4.4.2    pkgconfig_2.0.3  
## [25] rstudioapi_0.17.1 farver_2.1.2      digest_0.6.37     R6_2.5.1         
## [29] tidyselect_1.2.1  pillar_1.10.2     magrittr_2.0.3    bslib_0.8.0      
## [33] withr_3.0.2       tools_4.4.2       gtable_0.3.6      cachem_1.1.0