From f5dd9e88d2c2eef16619cd136645f4e18bb8995b Mon Sep 17 00:00:00 2001 From: dylanbenzi Date: Mon, 21 Jul 2025 16:09:05 -0400 Subject: [PATCH] remove old dashboard --- dashboard.Rmd.old | 236 ---------------------------------------------- 1 file changed, 236 deletions(-) delete mode 100644 dashboard.Rmd.old diff --git a/dashboard.Rmd.old b/dashboard.Rmd.old deleted file mode 100644 index 16a96e2..0000000 --- a/dashboard.Rmd.old +++ /dev/null @@ -1,236 +0,0 @@ ---- -title: "Hurricane Normalization App" -runtime: shiny -output: - flexdashboard::flex_dashboard: - orientation: rows - vertical_layout: fill - navbar: - - {title: "Home", icon: "fa-home", href: "#"} - - {title: "About", icon: "fa-info-circle"} - theme: - version: 4 - bootswatch: journal ---- - -```{r setup, include=FALSE} -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) - -setwd("/home/dylan/Personal/Projects/Hurricane Normalization/") - -pop <- read.csv("Data/population_with_projections.csv", stringsAsFactors = F) %>% - pivot_longer( - cols = starts_with("X"), - names_to = "year", - values_to = "pop", - ) %>% - mutate( - year = parse_number(year) - ) - -housing <- read.csv("Data/housing_units.csv", stringsAsFactors = F) %>% - pivot_longer( - cols = starts_with("X"), - names_to = "year", - values_to = "housing" - ) %>% - mutate( - year = parse_number(year) - ) - -counties <- pop %>% - left_join(housing %>% select(FIPS, year, housing), by = c("FIPS", "year")) %>% - pivot_longer( - cols = c("pop", "housing"), - names_to = "metric", - values_to = "value" - ) - -pop <- pop %>% - mutate( - FIPS = ifelse(nchar(FIPS) == 4, paste0("0", FIPS), FIPS), - state_fips = substr(FIPS, 1, 2), - county_fips = substr(FIPS, 3, 5) - ) %>% - rename(population = pop) %>% - select(!full_county_and_state:County & !county_state & !FIPS) - -housing <- housing %>% - mutate( - FIPS = ifelse(nchar(FIPS) == 4, paste0("0", FIPS), FIPS), - state_fips = substr(FIPS, 1, 2), - county_fips = substr(FIPS, 3, 5) - ) %>% - rename(housing_units = housing) %>% - select(!County.Full:County & !County.State & !FIPS) - -metrics.pop_and_housing <- pop %>% - left_join(housing, by = c("state_fips", "county_fips", "year")) - -donna <- read.csv("R/dataScripts/restructured/hurdat2/gis_counties.csv") - -donna <- donna %>% - filter(HURDAT_C_1 == "AL051960") %>% - mutate( - FIPS = as.character(FIPS) - ) - -donna <- donna %>% - mutate( - FIPS = case_when( - str_length(donna$FIPS) == 4 ~ paste0("0", donna$FIPS), - TRUE ~ donna$FIPS - ), - state_fips = substr(FIPS, 1, 2), - county_fips = substr(FIPS, 3, 5) - ) %>% - rename(year = Year) - -donna <- donna %>% - left_join(metrics.pop_and_housing, by = c("state_fips", "county_fips", "year")) - -donna <- donna %>% - select(Storm_Name, STATE_NAME, County_Name, state_fips, county_fips, population, housing_units) - -donna <- donna %>% - mutate(Storm_Name = substr(Storm_Name, 1, 5)) - -donna <- donna %>% - mutate( - FIPS = paste0(state_fips, county_fips) - ) %>% - select( - -state_fips, - -county_fips - ) - -donna <- donna %>% - select( - County = County_Name, - Population = population, - Housing = housing_units - ) - - -# 1-3 FL -# 4-10 NC -# 11-13 CT -# 14-16 NY - -``` - - -Dashboard -============================================= - -Row {data-height=100} ----------------------------------------------- -### {data-width=103} -```{r} -h6("Hurricane") -h3("Galveston 1900") -``` - -### {data-width=25} - -```{r} -valueBox("#18", caption = "Rank by population") -``` - -### {data-width=25} - -```{r} -valueBox("$58.11b", caption = "Loss by population", icon = "fa-user") -``` - -### {data-width=25} - -```{r} -valueBox("#37", caption = "Rank by housing") -``` - -### {data-width=25} - -```{r} -valueBox("$10.63b", caption = "Loss by housing", icon = "fa-house") -``` - -Row {data-height=400} ----------------------------------------------- - -### {data-width=50} - -```{r} -donna %>% - kbl() %>% - kable_styling(font_size = 16) %>% - pack_rows("Florida", 1, 3, label_row_css = "color: #fff") %>% - pack_rows("North Carolina", 4, 10, label_row_css = "color: #fff") %>% - pack_rows("Connecticut", 11, 13, label_row_css = "color: #fff") %>% - pack_rows("New York", 14, 16, label_row_css = "color: #fff") %>% - row_spec(1:16, color = "white") -``` - - -### {data-width=50} - -```{r} -output$worldMap <- renderLeaflet({ - leaflet() %>% - addTiles() %>% - setView(lng = 0, lat = 20, zoom = 2) %>% - addScaleBar(position = "bottomleft") %>% - addLayersControl( - baseGroups = c("Default", "Satellite", "Terrain"), - options = layersControlOptions(collapsed = FALSE) - ) %>% - addProviderTiles(providers$Esri.WorldImagery, group = "Satellite") %>% - addProviderTiles(providers$Stamen.Terrain, group = "Terrain") %>% - hideGroup("Satellite") %>% - hideGroup("Terrain") -}) - -output$map <- renderLeaflet({ - leaflet() %>% - addProviderTiles("Stadia.AlidadeSmoothDark", option = providerTileOptions(minZoom = 2, maxZoom = 18)) %>% - setView(lng = 0, lat = 20, zoom = 2) -}) - -#leafletOutput("map", height="100%") - -leafletOutput("worldMap", height = "100%") -``` - -Row {data-height=400} ---- - -### {data-width=50} - -```{r} -lines <- metrics.pop_and_housing %>% - filter(state_fips == "01" & county_fips == "087" & year >= 1960) - -output$lineChart <- renderPlot({ - ggplot(lines, aes()) -}) -``` - -### {data-width=50} -```{r eval=FALSE, include=FALSE} - -``` \ No newline at end of file