Last updated: 2019-03-03

Checks: 6 0

Knit directory: ncdc_storm_events/

This reproducible R Markdown analysis was created with workflowr (version 1.2.0). The Report tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20181114) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  docs/

Unstaged changes:
    Modified:   .gitignore

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
Rmd e7f7b6f Tim Trice 2019-03-03 Add Exploratory/Damages

library(DT)
library(glue)
library(lubridate)
library(tidyverse)
details <- 
  read_csv(
    file = here::here("./output/details.csv"), 
    col_types = cols(
      .default = col_character(),
      EPISODE_ID = col_integer(), 
      EVENT_ID = col_integer(),
      STATE_FIPS = col_integer(),
      CZ_FIPS = col_integer(),
      BEGIN_DATE_TIME = col_datetime(format = ""),
      END_DATE_TIME = col_datetime(format = ""),
      INJURIES_DIRECT = col_integer(),
      INJURIES_INDIRECT = col_integer(),
      DEATHS_DIRECT = col_integer(),
      DEATHS_INDIRECT = col_integer(),
      DAMAGE_PROPERTY = col_number(),
      DAMAGE_CROPS = col_number(),
      MAGNITUDE = col_double(),
      TOR_LENGTH = col_double(),
      TOR_WIDTH = col_double(),
      BEGIN_RANGE = col_integer(),
      END_RANGE = col_integer(),
      BEGIN_LAT = col_double(),
      BEGIN_LON = col_double(),
      END_LAT = col_double(),
      END_LON = col_double()
    )
  )

episode_narratives <- 
  read_csv(
    file = here::here("./output/episode_narratives.csv"), 
    col_types = cols()
  )

event_narratives <- 
  read_csv(
    file = here::here("./output/event_narratives.csv"), 
    col_types = cols(
      EPISODE_ID = col_integer(),
      EVENT_ID = col_integer(),
      EVENT_NARRATIVE = col_character()
    )
  )

Most expensive events (property)

details %>% 
  #' Apply filter to make query quicker
  filter(DAMAGE_PROPERTY > 1e6) %>% 
  mutate(YEAR = year(BEGIN_DATE_TIME)) %>% 
  select(EVENT_ID, STATE, YEAR, EVENT_TYPE, DAMAGE_PROPERTY) %>% 
  top_n(10) %>% 
  arrange(desc(DAMAGE_PROPERTY)) %>% 
  mutate_at(.vars = "DAMAGE_PROPERTY", .funs = scales::dollar) %>% 
  left_join(select(event_narratives, -EPISODE_ID), by = "EVENT_ID") %>% 
  datatable(rownames = FALSE, caption = "Top 10 Events by DAMAGE_PROPERTY")

Most expensive episodes (property)

details %>% 
  select(EPISODE_ID, DAMAGE_PROPERTY) %>% 
  filter(!is.na(EPISODE_ID)) %>% 
  group_by(EPISODE_ID) %>% 
  summarise(n = sum(DAMAGE_PROPERTY, na.rm = TRUE)) %>% 
  top_n(10L) %>% 
  arrange(desc(n)) %>%
  mutate_at(.vars = "n", .funs = scales::dollar) %>% 
  rename(DAMAGE_PROPERTY = n) %>% 
  left_join(episode_narratives, by = "EPISODE_ID") %>% 
  datatable(rownames = FALSE, caption = "Top 10 Episodes by DAMAGE_PROPERTY")

Most expensive events (crops)

details %>% 
  #' Apply filter to make query quicker
  filter(DAMAGE_CROPS > 1e6) %>% 
  mutate(YEAR = year(BEGIN_DATE_TIME)) %>% 
  select(EVENT_ID, STATE, YEAR, EVENT_TYPE, DAMAGE_CROPS) %>% 
  top_n(10) %>% 
  arrange(desc(DAMAGE_CROPS)) %>%
  mutate_at(.vars = "DAMAGE_CROPS", .funs = scales::dollar) %>% 
  left_join(select(event_narratives, -EPISODE_ID), by = "EVENT_ID") %>% 
  datatable(rownames = FALSE, caption = "Top 10 Events by DAMAGE_CROPS")

Most expensive episodes (crops)

details %>% 
  select(EPISODE_ID, DAMAGE_CROPS) %>% 
  filter(!is.na(EPISODE_ID)) %>% 
  group_by(EPISODE_ID) %>% 
  summarise(n = sum(DAMAGE_CROPS, na.rm = TRUE)) %>% 
  top_n(10L) %>% 
  arrange(desc(n)) %>%
  mutate_at(.vars = "n", .funs = scales::dollar) %>% 
  rename(DAMAGE_CROPS = n) %>% 
  left_join(episode_narratives, by = "EPISODE_ID") %>% 
  datatable(rownames = FALSE, caption = "Top 10 Episodes by DAMAGE_CROPS")


devtools::session_info()
─ Session info ──────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.5.2 (2018-12-20)
 os       Ubuntu 18.04.2 LTS          
 system   x86_64, linux-gnu           
 ui       X11                         
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/Chicago             
 date     2019-03-03                  

─ Packages ──────────────────────────────────────────────────────────────
 package     * version date       lib source        
 assertthat    0.2.0   2017-04-11 [1] CRAN (R 3.5.2)
 backports     1.1.3   2018-12-14 [1] CRAN (R 3.5.2)
 broom         0.5.1   2018-12-05 [1] CRAN (R 3.5.2)
 callr         3.1.1   2018-12-21 [1] CRAN (R 3.5.2)
 cellranger    1.1.0   2016-07-27 [1] CRAN (R 3.5.2)
 cli           1.0.1   2018-09-25 [1] CRAN (R 3.5.2)
 colorspace    1.4-0   2019-01-13 [1] CRAN (R 3.5.2)
 crayon        1.3.4   2017-09-16 [1] CRAN (R 3.5.2)
 crosstalk     1.0.0   2016-12-21 [1] CRAN (R 3.5.2)
 desc          1.2.0   2018-05-01 [1] CRAN (R 3.5.2)
 devtools      2.0.1   2018-10-26 [1] CRAN (R 3.5.2)
 digest        0.6.18  2018-10-10 [1] CRAN (R 3.5.2)
 dplyr       * 0.8.0.1 2019-02-15 [1] CRAN (R 3.5.2)
 DT          * 0.5     2018-11-05 [1] CRAN (R 3.5.2)
 evaluate      0.12    2018-10-09 [1] CRAN (R 3.5.2)
 forcats     * 0.3.0   2018-02-19 [1] CRAN (R 3.5.2)
 fs            1.2.6   2018-08-23 [1] CRAN (R 3.5.2)
 generics      0.0.2   2018-11-29 [1] CRAN (R 3.5.2)
 ggplot2     * 3.1.0   2018-10-25 [1] CRAN (R 3.5.2)
 git2r         0.24.0  2019-01-07 [1] CRAN (R 3.5.2)
 glue        * 1.3.0   2018-07-17 [1] CRAN (R 3.5.2)
 gtable        0.2.0   2016-02-26 [1] CRAN (R 3.5.2)
 haven         2.0.0   2018-11-22 [1] CRAN (R 3.5.2)
 here          0.1     2017-05-28 [1] CRAN (R 3.5.2)
 hms           0.4.2   2018-03-10 [1] CRAN (R 3.5.2)
 htmltools     0.3.6   2017-04-28 [1] CRAN (R 3.5.2)
 htmlwidgets   1.3     2018-09-30 [1] CRAN (R 3.5.2)
 httpuv        1.4.5.1 2018-12-18 [1] CRAN (R 3.5.2)
 httr          1.4.0   2018-12-11 [1] CRAN (R 3.5.2)
 jsonlite      1.6     2018-12-07 [1] CRAN (R 3.5.2)
 knitr         1.21    2018-12-10 [1] CRAN (R 3.5.2)
 later         0.8.0   2019-02-11 [1] CRAN (R 3.5.2)
 lattice       0.20-38 2018-11-04 [1] CRAN (R 3.5.2)
 lazyeval      0.2.1   2017-10-29 [1] CRAN (R 3.5.2)
 lubridate   * 1.7.4   2018-04-11 [1] CRAN (R 3.5.2)
 magrittr      1.5     2014-11-22 [1] CRAN (R 3.5.2)
 memoise       1.1.0   2017-04-21 [1] CRAN (R 3.5.2)
 mime          0.6     2018-10-05 [1] CRAN (R 3.5.2)
 modelr        0.1.2   2018-05-11 [1] CRAN (R 3.5.2)
 munsell       0.5.0   2018-06-12 [1] CRAN (R 3.5.2)
 nlme          3.1-137 2018-04-07 [1] CRAN (R 3.5.2)
 pillar        1.3.1   2018-12-15 [1] CRAN (R 3.5.2)
 pkgbuild      1.0.2   2018-10-16 [1] CRAN (R 3.5.2)
 pkgconfig     2.0.2   2018-08-16 [1] CRAN (R 3.5.2)
 pkgload       1.0.2   2018-10-29 [1] CRAN (R 3.5.2)
 plyr          1.8.4   2016-06-08 [1] CRAN (R 3.5.2)
 prettyunits   1.0.2   2015-07-13 [1] CRAN (R 3.5.2)
 processx      3.2.1   2018-12-05 [1] CRAN (R 3.5.2)
 promises      1.0.1   2018-04-13 [1] CRAN (R 3.5.2)
 ps            1.3.0   2018-12-21 [1] CRAN (R 3.5.2)
 purrr       * 0.2.5   2018-05-29 [1] CRAN (R 3.5.2)
 R6            2.3.0   2018-10-04 [1] CRAN (R 3.5.2)
 Rcpp          1.0.0   2018-11-07 [1] CRAN (R 3.5.2)
 readr       * 1.3.1   2018-12-21 [1] CRAN (R 3.5.2)
 readxl        1.2.0   2018-12-19 [1] CRAN (R 3.5.2)
 remotes       2.0.2   2018-10-30 [1] CRAN (R 3.5.2)
 rlang         0.3.1   2019-01-08 [1] CRAN (R 3.5.2)
 rmarkdown     1.11    2018-12-08 [1] CRAN (R 3.5.2)
 rprojroot     1.3-2   2018-01-03 [1] CRAN (R 3.5.2)
 rstudioapi    0.9.0   2019-01-09 [1] CRAN (R 3.5.2)
 rvest         0.3.2   2016-06-17 [1] CRAN (R 3.5.2)
 scales        1.0.0   2018-08-09 [1] CRAN (R 3.5.2)
 sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.5.2)
 shiny         1.2.0   2018-11-02 [1] CRAN (R 3.5.2)
 stringi       1.2.4   2018-07-20 [1] CRAN (R 3.5.2)
 stringr     * 1.3.1   2018-05-10 [1] CRAN (R 3.5.2)
 tibble      * 2.0.1   2019-01-12 [1] CRAN (R 3.5.2)
 tidyr       * 0.8.2   2018-10-28 [1] CRAN (R 3.5.2)
 tidyselect    0.2.5   2018-10-11 [1] CRAN (R 3.5.2)
 tidyverse   * 1.2.1   2017-11-14 [1] CRAN (R 3.5.2)
 usethis       1.4.0   2018-08-14 [1] CRAN (R 3.5.2)
 whisker       0.3-2   2013-04-28 [1] CRAN (R 3.5.2)
 withr         2.1.2   2018-03-15 [1] CRAN (R 3.5.2)
 workflowr     1.2.0   2019-02-14 [1] CRAN (R 3.5.2)
 xfun          0.4     2018-10-23 [1] CRAN (R 3.5.2)
 xml2          1.2.0   2018-01-24 [1] CRAN (R 3.5.2)
 xtable        1.8-3   2018-08-29 [1] CRAN (R 3.5.2)
 yaml          2.2.0   2018-07-25 [1] CRAN (R 3.5.2)

[1] /usr/local/lib/R/site-library
[2] /usr/lib/R/site-library
[3] /usr/lib/R/library