#' Import crash narratives
#'
#' Import crash narratives.
#' @inheritParams import_db_data
#'
#' @return dataframe of crash narratives
#' @export
#'
#' @examples
#' import_narrative(db_loc = "C:/data/crashes_duck.duckdb", years = c("17","18"))
import_narrative <-
function(db_loc = NULL,
years) {
con <- duckdb::dbConnect(duckdb::duckdb(), dbdir = db_loc)
data_years = paste0("narrative", years, sep = "") # combines crashes with years to select data
combine_data <- #columns = c("RECDSTAT")
purrr::map_dfr(.x = data_years,
.f = read_narrative,
con = con)
duckdb::dbDisconnect(con, shutdown = TRUE)
combine_data
}
read_narrative <- function(data_years, filepath, filetype, con) {
read_narr = dplyr::tbl(con, data_years) |> dplyr::collect() |> data.table::as.data.table()
return(read_narr)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.