Nothing
knitr::opts_chunk$set(echo = F) library(rfars) library(stringr) library(dplyr) library(knitr) library(tidyr)
rfars
comes pre-loaded with searchable codebooks. Note that these are not data
dictionaries as they do not define data elements, but their labels are quite
informative.
You can find the data dictionaries here:
Access the codebooks in RStudio with:
View(rfars::fars_codebook) View(rfars::gescrss_codebook)
The tables below show the 2015 and 2020 values for the FARS codebook. The GES/CRSS data files contain many of the same elements as the FARS data files. The codebook changes slightly every year. Please take care when using multiple years of data.
temp <- fars_codebook %>% mutate(value_label = gsub("`", "", value_label)) %>% separate_rows(years) %>% rename(year=years) %>% filter(!(name_ncsa %in% c("VPICMODEL", "MAK_MOD", "STATE", "VPICMAKE", "ALC_RES", "DR_WGT", "AGE", "PBAGE", "DRUGRES1", "DRUGRES2", "DRUGRES3", "TRAV_SP"))) %>% filter(!(str_detect(name_ncsa, "HOUR"))) %>% filter(!(str_detect(name_ncsa, "MINUTE"))) %>% filter(!(str_detect(name_ncsa, "_HR"))) %>% filter(!(str_detect(name_ncsa, "_MIN"))) %>% filter(value != value_label) %>% filter(year %in% c(2015, 2020)) %>% select(label, name_rfars, file, value, year, value_label) %>% # Filter out numeric 1:1 translations (e.g., Age = 1 = 1, Speed = 50 = 50) mutate( v = ifelse(is.na(as.numeric(value)), "-x-x-x-x-x-x", as.numeric(value)), vl = ifelse(is.na(as.numeric(value_label)), "-x-x-x-x-x-x", as.numeric(value_label)) ) %>% filter(v != vl) %>% select(-v, -vl) %>% pivot_wider(names_from = "year", values_from = "value_label") %>% filter(!(is.na(`2015`) & is.na(`2020`))) %>% arrange(label) knitr::kable(temp, format = "pipe")
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.