Shiny App

library(shiny)
Warning: package 'shiny' was built under R version 4.3.3
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.3     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(tigris)
Warning: package 'tigris' was built under R version 4.3.1
To enable caching of data, set `options(tigris_use_cache = TRUE)`
in your R script or .Rprofile.
texas_counties <- list_counties("texas")
tx_counties <- texas_counties |> select(county) |> mutate(county = toupper(county))

tx_counties |> head()
storms <- readRDS("data-processed/02-storm-data.rds")

storms |> head()
#Define UI ----
ui <- fluidPage(
    
    # Copy the line below to make a select box 
    selectInput("select", label = h3("Select box"), 
                choices = tx_counties, 
                multiple = TRUE),
    
    dataTableOutput(outputId = "stormtable")
  )
`shiny::dataTableOutput()` is deprecated as of shiny 1.8.1.
Please use `DT::DTOutput()` instead.
Since you have a suitable version of DT (>= v0.32.1), shiny::dataTableOutput() will automatically use DT::DTOutput() under-the-hood.
If this happens to break your app, set `options(shiny.legacy.datatable = TRUE)` to get the legacy datatable implementation (or `FALSE` to squelch this message).
See <https://rstudio.github.io/DT/shiny.html> for more information.
# Define server logic ----
server <- function(input, output) {
  output$stormtable <- DT::renderDataTable({
    if (is.null(input$select) || length(input$select) == 0) {
      # No selection made, return the full dataset
      filtered_data <- storms
    } else {
      # Filter the dataset based on selections
      filtered_data <- storms %>%
        filter(location %in% input$select)
    }
    
    # Return the datatable
    DT::datatable(filtered_data)
  })
}

# Run the app ----
shinyApp(ui = ui, server = server)