mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-30 05:08:57 +00:00
98 lines
1.9 KiB
R
98 lines
1.9 KiB
R
library(flexdashboard)
|
|
library(shiny)
|
|
library(leaflet)
|
|
library(DT)
|
|
library(dplyr)
|
|
library(DBI)
|
|
library(tidyr)
|
|
library(ggplot2)
|
|
library(plotly)
|
|
library(viridis)
|
|
library(lubridate)
|
|
library(scales)
|
|
library(readr)
|
|
library(stringr)
|
|
library(kableExtra)
|
|
library(bslib)
|
|
library(dygraphs)
|
|
library(tidyverse)
|
|
library(sf)
|
|
library(shinyBS)
|
|
library(xts)
|
|
library(tigris)
|
|
library(caret)
|
|
library(scales)
|
|
library(billboarder)
|
|
library(shinyWidgets)
|
|
library(paletteer)
|
|
library(shinyjs)
|
|
library(quarto)
|
|
library(bsicons)
|
|
|
|
APP_DIR <- getwd()
|
|
|
|
cache_dir <- file.path(APP_DIR, "cache")
|
|
cache_logfile <- file.path(APP_DIR, "cachelog")
|
|
|
|
source(file = "queries.R")
|
|
|
|
useShinyjs()
|
|
|
|
# pull static data
|
|
loss_storms <- get_all_loss_storms()
|
|
|
|
latest_normalized_losses <- get_latest_aggregate_losses()
|
|
|
|
all_conus_landfalls <- get_all_conus_landfalls()
|
|
|
|
all_lf_type_storms <- get_all_lf_type_landfalls()
|
|
|
|
storm_coverage <- get_storm_data_coverage() %>%
|
|
mutate(
|
|
data = trimws(paste(
|
|
"<span class=\"badge bg-primary\">HURDAT2</span>",
|
|
ifelse(
|
|
as.logical(has_fatality_data),
|
|
"<span class=\"badge bg-danger\">Fatality</span>",
|
|
""
|
|
),
|
|
ifelse(
|
|
as.logical(has_cost_data),
|
|
"<span class=\"badge bg-success\">Cost</span>",
|
|
""
|
|
)
|
|
))
|
|
) %>%
|
|
mutate(total_direct_deaths = as.integer(total_direct_deaths)) %>%
|
|
select(
|
|
hurdatid,
|
|
storm_name,
|
|
storm_year,
|
|
data,
|
|
mmh,
|
|
mmp,
|
|
total_direct_deaths,
|
|
total_observations,
|
|
max_category,
|
|
max_windspeed,
|
|
min_pressure,
|
|
has_fatality_data,
|
|
has_cost_data
|
|
)
|
|
|
|
dt_yr_range <- range(storm_coverage$storm_year, na.rm = TRUE)
|
|
dt_death_max <- max(storm_coverage$total_direct_deaths, na.rm = TRUE)
|
|
dt_mmh_max <- max(storm_coverage$mmh, na.rm = TRUE)
|
|
dt_mmp_max <- max(storm_coverage$mmp, na.rm = TRUE)
|
|
|
|
onStop(function() {
|
|
poolClose(con)
|
|
})
|
|
|
|
storm_selection <- reactiveValues(
|
|
storm_year = NULL,
|
|
storm_name = NULL,
|
|
storm_basin = NULL,
|
|
hurdatid = NULL
|
|
)
|