library(rfars) library(dplyr) library(stringr)
rfars comes pre-loaded with searchable codebooks, compiled from SAS format
files and the User Manuals (see: FARS Analytical User's
Manual and
CRSS Analytical User's
Manual).
Access the codebooks in RStudio with:
View(rfars::fars_codebook) View(rfars::gescrss_codebook)
It can be helpful to search the codebooks for certain concepts. The examples below illustrate the content of the codebooks and how variables change over time.
Here we search for the word alcohol in any of the codebook fields, including the names of tables, various versions of variable names, the definition, all value labels, and additional information from the User Manual if present.
cb <- rfars::fars_codebook %>% filter(if_any(everything(), ~ str_detect(., "alcohol"))) distinct(cb, source, file, name_ncsa, name_rfars, label, Definition, `Additional Information`) %>% knitr::kable(format = "html")
The drinking variable changed in a very minor way:
filter(cb, name_rfars == "drinking") %>% distinct(name_rfars, value_label, `2014`, `2015`, `2016`, `2017`, `2018`, `2019`, `2020`, `2021`, `2022`, `2023`) %>% knitr::kable(format = "html")
But the variable for driver distraction changed names in 2020:
filter(cb, name_rfars %in% c("mdrdstrd", "drdistract")) %>% distinct(name_rfars, value_label, `2014`, `2015`, `2016`, `2017`, `2018`, `2019`, `2020`, `2021`, `2022`, `2023`) %>% arrange(value_label, name_rfars) %>% knitr::kable(format = "html")
As another example, the per_typ variable has undergone more substantial changes over time.
filter(rfars::fars_codebook, name_rfars == "per_typ") %>% distinct(name_rfars, value_label, `2014`, `2015`, `2016`, `2017`, `2018`, `2019`, `2020`, `2021`, `2022`, `2023`) %>% arrange(value_label, name_rfars) %>% knitr::kable(format = "html")
Users of rfars and FARS data in general are strongly encouraged to User Manuals for further guidance.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.