Setup
library (reactable)
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
Read in the data
I am using the data from O2-BasicAnalysis because it has the correct columns already.
storms <- read_rds ("data-processed/02-storm-data.rds" )
Reactable Interactive Table
I wanted to create an interative data table that I could search and filter for records. To do this with reactable, I made the table “searchable” to add the top search bar. Then I made event type, location and county/zone filterable. I also made each damage column able to be arranges in desc or asc order with the defaultSortOrder. I did the same with the date column.
reactable (
storms,
searchable = TRUE ,
columns = list (
event_type = colDef (name = "Event Type" , filterable = TRUE ),
location = colDef (name = "Location" , filterable = TRUE ),
CZ_type = colDef (name = "County/Zone" ),
FIPS = colDef (name = "FIPS Code" , filterable = TRUE ),
total_damages = colDef (name = "Total Damages" , align = "center" , defaultSortOrder = "desc" ),
damage_val_prop = colDef (align = "center" , name = "Damages to Property" , defaultSortOrder = "desc" ),
damage_val_crop = colDef (align = "center" , name = "Damages to Crops" , defaultSortOrder = "desc" ),
begin_date = colDef (name = "Start Date" , defaultSortOrder = "asc" )
)
)