View source: R/database_imports.R
import_db_data | R Documentation |
This imports all data based on crash db type, years selected, and columns selected. It combines old and new crash data into a single dataframe. It renames columns of the old db to match db and renames some variables, such as CRSHSVR, to match new db. Note: if an old db is imported, all columns will be imported.
import_db_data(
db_loc = "C:/data/crashes_duck.duckdb",
db_type = "crash",
years = c("21"),
columns = c("CRSHSVR"),
filter_by = NULL
)
db_loc |
location of crash database file ("C:/data/crashes_duck.duckdb") |
db_type |
Type of database - any one of "crash", "vehicle", or "person" |
years |
Year(s) of db data c("20", "21"). |
columns |
Columns to be imported. For the new db these columns will always be imported (if applicable): "CRSHNMBR", "CRSHDATE", "CNTYCODE ,"CRSHSVR", "UNITNMBR", "ROLE","VEHTYPE","WISINJ", "UNITPRSN", "UNITTYPE". Columns with multiples, like DRVRPC and ANMLTY, only the first part without the number should be inputted. For old db, all columns will be imported. If columns = "all", all columns will be selected. |
filter_by |
Option to filter by county, separated by a comma. Use "county:Dane, Rock" |
Note that DRVRFLAG is derived differently for old and new db. New db defines a driver of any MV, while old db also include non-motorists.
df of either crash, vehicle or person. 'year' column.
import_db_data(db_loc = "C:/data/crashes_duck.duckdb", db_type = "crash",
years = c("16", "17","18"), columns = c("DRVRPC"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.