Dementia Crash Data Integration with Smart Location Database

CRIS, Census Block Group, and SLD Data Preparation

1 Project Overview

This R Markdown file prepares the dementia-related crash dataset by linking three files:

  1. The original dementia crash file
  2. CRIS crash locations with Census Block Group identifiers
  3. Texas Smart Location Database variables

The workflow is designed to be reproducible, transparent, and easy to modify for future analysis.

2 Load Required Packages

# ================================================================
# Load packages
# Missing packages are installed automatically
# ================================================================

required_packages <- c(
  "readxl",
  "data.table",
  "dplyr",
  "janitor",
  "skimr",
  "knitr",
  "DT"
)

missing_packages <- required_packages[
  !(required_packages %in% installed.packages()[, "Package"])
]

if (length(missing_packages) > 0) {
  install.packages(missing_packages)
}

invisible(lapply(required_packages, library, character.only = TRUE))

3 Define File Paths

# ================================================================
# Define project paths
# Update these paths if the project folder changes
# ================================================================

dementia_data_dir <- "C:/Users/mvx13/OneDrive - Texas State University/Papers/2026/2027_TRBAM/Data/Dementia/OriData"

cris_data_dir <- "C:/Users/mvx13/OneDrive - Texas State University/Papers/2026/2027_TRBAM/CRIS"

dementia_file <- file.path(dementia_data_dir, "Dementia_2017_2025b.xlsx")

crash_location_file <- file.path(cris_data_dir, "crash_locations_with_blockgroup.csv")

sld_file <- file.path(cris_data_dir, "TX_SLD.csv")

# Check whether files exist before reading
file_check <- data.frame(
  file_type = c("Dementia crash data", "Crash location with block group", "Texas SLD data"),
  file_path = c(dementia_file, crash_location_file, sld_file),
  file_exists = file.exists(c(dementia_file, crash_location_file, sld_file))
)

knitr::kable(file_check, caption = "Input File Availability Check")
Table 3.1: Input File Availability Check
file_type file_path file_exists
Dementia crash data C:/Users/mvx13/OneDrive - Texas State University/Papers/2026/2027_TRBAM/Data/Dementia/OriData/Dementia_2017_2025b.xlsx TRUE
Crash location with block group C:/Users/mvx13/OneDrive - Texas State University/Papers/2026/2027_TRBAM/CRIS/crash_locations_with_blockgroup.csv TRUE
Texas SLD data C:/Users/mvx13/OneDrive - Texas State University/Papers/2026/2027_TRBAM/CRIS/TX_SLD.csv TRUE

4 Read Input Data

4.1 Dementia Crash Data

# ================================================================
# Read original dementia-related crash dataset
# ================================================================

dem <- readxl::read_excel(dementia_file) |>
  janitor::clean_names()

# Basic structure
dim_dem <- dim(dem)

cat("Rows:", dim_dem[1], "\n")
#> Rows: 4781
cat("Columns:", dim_dem[2], "\n")
#> Columns: 153
# Preview data
head(dem)
#> # A tibble: 6 × 153
#>   crash_id crash_date crash_time crash_speed_limit wthr_cond_id light_cond_id   
#>      <dbl> <chr>      <chr>                  <dbl> <chr>        <chr>           
#> 1 15517460 01/01/2017 08:36 PM                  55 Clear        Dark, Not Light…
#> 2 15525161 01/06/2017 06:05 PM                  45 Clear        Dark, Not Light…
#> 3 15525268 01/02/2017 09:09 PM                  30 Clear        Dark, Lighted   
#> 4 15526895 01/06/2017 06:43 AM                  35 Clear        Dark, Lighted   
#> 5 15531050 01/09/2017 05:27 PM                  65 Clear        Daylight        
#> 6 15532035 01/09/2017 11:25 AM                  60 Clear        Daylight        
#> # ℹ 147 more variables: entr_road_id <chr>, road_type_id <chr>,
#> #   road_algn_id <chr>, surf_cond_id <chr>, traffic_cntl_id <chr>,
#> #   investigat_notify_time <chr>, investigat_arrv_time <chr>,
#> #   harm_evnt_id <chr>, intrsct_relat_id <chr>, fhe_collsn_id <chr>,
#> #   obj_struck_id <chr>, othr_factr_id <chr>, road_part_adj_id <chr>,
#> #   road_cls_id <chr>, road_relat_id <chr>, cnty_id <chr>, city_id <chr>,
#> #   latitude <dbl>, longitude <dbl>, onsys_fl <chr>, rural_fl <chr>, …

4.2 CRIS Crash Location Data

# ================================================================
# Read crash location file with Census Block Group GEOID
# ================================================================

sld1 <- data.table::fread(crash_location_file) |>
  janitor::clean_names()

# Basic structure
dim_sld1 <- dim(sld1)

cat("Rows:", dim_sld1[1], "\n")
#> Rows: 5109746
cat("Columns:", dim_sld1[2], "\n")
#> Columns: 8
# Preview data
head(sld1)
#>    crash_id latitude longitude  year      geoid10      geoid20  cbsa
#>       <int>    <num>     <num> <int>        <i64>        <i64> <int>
#> 1: 14570071    31.78   -106.52  2017 481410014002 481410014002 21340
#> 2: 14881309    31.65   -106.27  2017 481410104081 481410104081 21340
#> 3: 14963691    29.63    -95.17  2017 482013240002 482013240002 26420
#> 4: 14963927    32.74    -96.68  2017 481130091053 481130091053 19100
#> 5: 14990459    30.11    -95.60  2017 482015554011 482015554011 26420
#> 6: 15138336    32.81    -96.81  2017 481130005001 481130005001 19100
#>                               cbsa_name
#>                                  <char>
#> 1:                          El Paso, TX
#> 2:                          El Paso, TX
#> 3: Houston-The Woodlands-Sugar Land, TX
#> 4:      Dallas-Fort Worth-Arlington, TX
#> 5: Houston-The Woodlands-Sugar Land, TX
#> 6:      Dallas-Fort Worth-Arlington, TX

4.3 Texas Smart Location Database

# ================================================================
# Read Texas Smart Location Database file
# ================================================================

sld2 <- data.table::fread(sld_file) |>
  janitor::clean_names()

# Basic structure
dim_sld2 <- dim(sld2)

cat("Rows:", dim_sld2[1], "\n")
#> Rows: 15811
cat("Columns:", dim_sld2[2], "\n")
#> Columns: 182
# Preview data
head(sld2)
#>       v1      geoid10      geoid20 statefp countyfp tractce blkgrpce   csa
#>    <int>        <i64>        <i64>   <int>    <int>   <int>    <int> <int>
#> 1:     1 481130078254 481130078254      48      113    7825        4   206
#> 2:     2 481130078252 481130078252      48      113    7825        2   206
#> 3:     3 481130078253 481130078253      48      113    7825        3   206
#> 4:     4 481130078241 481130078241      48      113    7824        1   206
#> 5:     5 481130078242 481130078242      48      113    7824        2   206
#> 6:     6 481130078271 481130078271      48      113    7827        1   206
#>                    csa_name  cbsa                       cbsa_name cbsa_pop
#>                      <char> <int>                          <char>    <int>
#> 1: Dallas-Fort Worth, TX-OK 19100 Dallas-Fort Worth-Arlington, TX  7189384
#> 2: Dallas-Fort Worth, TX-OK 19100 Dallas-Fort Worth-Arlington, TX  7189384
#> 3: Dallas-Fort Worth, TX-OK 19100 Dallas-Fort Worth-Arlington, TX  7189384
#> 4: Dallas-Fort Worth, TX-OK 19100 Dallas-Fort Worth-Arlington, TX  7189384
#> 5: Dallas-Fort Worth, TX-OK 19100 Dallas-Fort Worth-Arlington, TX  7189384
#> 6: Dallas-Fort Worth, TX-OK 19100 Dallas-Fort Worth-Arlington, TX  7189384
#>    cbsa_emp cbsa_wrk ac_total ac_water ac_land ac_unpr tot_pop count_hu    hh
#>       <int>    <int>    <num>    <num>   <num>   <num>   <int>    <int> <int>
#> 1:  3545715  3364458    73.60        0   73.60   73.60    1202      460   423
#> 2:  3545715  3364458   119.83        0  119.83  119.21     710      409   409
#> 3:  3545715  3364458    26.37        0   26.37   26.37     737      365   329
#> 4:  3545715  3364458   119.06        0  119.06  119.06     904      384   384
#> 5:  3545715  3364458   169.93        0  169.93  148.74     948      343   343
#> 6:  3545715  3364458    50.69        0   50.69   50.69    1336      556   497
#>    p_wrk_age auto_own0 pct_ao0 auto_own1 pct_ao1 auto_own2p pct_ao2p workers
#>        <num>     <int>   <num>     <int>   <num>      <int>    <num>   <int>
#> 1:     0.549        69 0.16312        39  0.0922        315   0.7447     412
#> 2:     0.466         0 0.00000       168  0.4108        241   0.5892     395
#> 3:     0.811        19 0.05775       143  0.4347        167   0.5076     463
#> 4:     0.638         0 0.00000        43  0.1120        341   0.8880     431
#> 5:     0.506         5 0.01458        67  0.1953        271   0.7901     579
#> 6:     0.588        33 0.06640       351  0.7062        113   0.2274     586
#>    r_low_wage_w r_med_wage_w r_hi_wage_wk r_pctlowwa tot_emp e5_ret e5_off
#>           <int>        <int>        <int>      <num>   <int>  <int>  <int>
#> 1:           99          122          191     0.2403      66     20      3
#> 2:           76          107          212     0.1924      25      7      0
#> 3:          136          189          138     0.2937       0      0      0
#> 4:           60           69          302     0.1392     253     26      0
#> 5:           91           84          404     0.1572      32      0      2
#> 6:          143          237          206     0.2440       3      0      1
#>    e5_ind e5_svc e5_ent e8_ret e8_off e8_ind e8_svc e8_ent e8_ed e8_hlth e8_pub
#>     <int>  <int>  <int>  <int>  <int>  <int>  <int>  <int> <int>   <int>  <int>
#> 1:      0     19     24     20      3      0     15     24     0       4      0
#> 2:      3     15      0      7      0      3     13      0     0       2      0
#> 3:      0      0      0      0      0      0      0      0     0       0      0
#> 4:     25     47    155     26      0     25      3    155     2      42      0
#> 5:     10     20      0      0      2     10     19      0     0       1      0
#> 6:      0      2      0      0      1      0      2      0     0       0      0
#>    e_low_wage_w e_med_wage_w e_hi_wage_wk e_pct_low_wa    d1a    d1b     d1c
#>           <int>        <int>        <int>        <num>  <num>  <num>   <num>
#> 1:           21           27           18       0.3182  6.250 16.333 0.89680
#> 2:           10            4           11       0.4000  3.431  5.956 0.20971
#> 3:            0            0            0       0.0000 13.843 27.952 0.00000
#> 4:          121           87           45       0.4783  3.225  7.593 2.12497
#> 5:            6            9           17       0.1875  2.306  6.373 0.21514
#> 6:            2            1            0       0.6667 10.969 26.358 0.05919
#>    d1c5_ret d1c5_off d1c5_ind d1c5_svc d1c5_ent d1c8_ret d1c8_off d1c8_ind
#>       <num>    <num>    <num>    <num>    <num>    <num>    <num>    <num>
#> 1:  0.27176  0.04076  0.00000  0.25817   0.3261  0.27176  0.04076  0.00000
#> 2:  0.05872  0.00000  0.02516  0.12582   0.0000  0.05872  0.00000  0.02516
#> 3:  0.00000  0.00000  0.00000  0.00000   0.0000  0.00000  0.00000  0.00000
#> 4:  0.21838  0.00000  0.20998  0.39476   1.3019  0.21838  0.00000  0.20998
#> 5:  0.00000  0.01345  0.06723  0.13446   0.0000  0.00000  0.01345  0.06723
#> 6:  0.00000  0.01973  0.00000  0.03946   0.0000  0.00000  0.01973  0.00000
#>    d1c8_svc d1c8_ent d1c8_ed d1c8_hlth d1c8_pub    d1d d1_flag d2a_jphh
#>       <num>    <num>   <num>     <num>    <num>  <num>   <int>    <num>
#> 1:  0.20382   0.3261  0.0000  0.054351        0  7.147       0 0.156028
#> 2:  0.10905   0.0000  0.0000  0.016777        0  3.641       0 0.061125
#> 3:  0.00000   0.0000  0.0000  0.000000        0 13.843       0 0.000000
#> 4:  0.02520   1.3019  0.0168  0.352761        0  5.350       0 0.658854
#> 5:  0.12774   0.0000  0.0000  0.006723        0  2.521       0 0.093294
#> 6:  0.03946   0.0000  0.0000  0.000000        0 11.028       0 0.006036
#>    d2b_e5mix d2b_e5mixa d2b_e8mix d2b_e8mixa d2a_ephhm d2c_trpmx1 d2c_trpmx2
#>        <num>      <num>     <num>      <num>     <num>      <num>      <num>
#> 1:    0.8863     0.7634    0.8554     0.6621   0.34891    0.52630    0.58592
#> 2:    0.8350     0.5700    0.8317     0.5545   0.19705    0.24848    0.27131
#> 3:    0.0000     0.0000    0.0000     0.0000   0.00000    0.00000    0.00000
#> 4:    0.7757     0.6682    0.6428     0.5538   0.68283    0.62072    0.67794
#> 5:    0.7560     0.5160    0.6886     0.4591   0.26147    0.24774    0.25899
#> 6:    0.9183     0.3955    0.9183     0.3061   0.03686    0.03689    0.04107
#>                                    d2c_tripeq d2r_jobpop d2r_wrkemp d2a_wrkemp
#>                                         <num>      <num>      <num>      <num>
#> 1: 0.2871283108620000246169468027801485732198   0.104101    0.27615      6.242
#> 2: 0.0020326803243699998607896262114991259295   0.068027    0.11905     15.800
#> 3: 0.3678794411710000211712667805841192603111   0.000000    1.00000      0.000
#> 4: 0.5963509803509999818160736140271183103323   0.437338    0.73977      1.704
#> 5: 0.0079026488713299994359751110550860175863   0.065306    0.10475     18.094
#> 6: 0.0000000000000000000000000000000000008068   0.004481    0.01019    195.333
#>                                                                                 d2c_wremlx
#>                                                                                      <num>
#> 1: 0.0052874232904900004062498375390077853808179497718811035156250000000000000000000000000
#> 2: 0.0000003736299379889999847624559858871862161322496831417083740234375000000000000000000
#> 3: 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#> 4: 0.4948219330949999994473387232574168592691421508789062500000000000000000000000000000000
#> 5: 0.0000000376945618842000019685888057008327223229571245610713958740234375000000000000000
#> 6: 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000004
#>      d3a   d3aao  d3amm  d3apo     d3b  d3bao d3bmm3 d3bmm4 d3bpo3 d3bpo4   d4a
#>    <num>   <num>  <num>  <num>   <num>  <num>  <num>  <num>  <num>  <num> <num>
#> 1: 23.53  0.0000 10.655 12.880 115.982  0.000  60.87  8.696  34.78 43.481 362.1
#> 2: 22.89  0.7551  2.859 19.279  80.146  5.341  10.68 10.682  85.45  5.341 718.8
#> 3: 14.21  6.1284  2.611  5.471  24.273 24.273   0.00 24.273   0.00  0.000 398.3
#> 4: 32.18  2.2086  9.324 20.646 141.604 21.502  21.50 32.252 134.39  5.375 386.2
#> 5: 22.06  2.2897  3.176 16.593  65.308  3.766   0.00  7.533  75.33  7.533 638.4
#> 6: 23.21 15.0348  6.401  1.777   8.422 50.506  12.63  0.000   0.00  0.000 950.9
#>    d4b025   d4b050   d4c   d4d      d4e   d5ar   d5ae   d5br  d5be      d5cr
#>     <num>    <num> <num> <num>    <num>  <int>  <int>  <int> <int>     <num>
#> 1:      0 0.000000  4.33 37.65 0.003602 433601 303660 135362 53504 0.0003979
#> 2:      0 0.009516  4.33 23.13 0.006099 386504 272135 236885 90089 0.0003547
#> 3:      0 0.000000  3.00 72.82 0.004071 404573 288925 230587 82815 0.0003713
#> 4:      0 0.515377  6.67 35.85 0.007378 423099 298058 168433 79657 0.0003883
#> 5:      0 0.248922  6.67 25.12 0.007036 335700 238166 120826 48682 0.0003081
#> 6:      0 0.094844  3.00 37.88 0.002246 402287 289607 138562 52583 0.0003692
#>     d5cri      d5ce  d5cei      d5dr  d5dri      d5de  d5dei d2a_ranked
#>     <num>     <num>  <num>     <num>  <num>     <num>  <num>      <int>
#> 1: 0.7859 0.0003576 0.8413 0.0005251 0.1847 0.0004756 0.1377          6
#> 2: 0.7005 0.0003205 0.7540 0.0009189 0.3232 0.0008008 0.2319          3
#> 3: 0.7333 0.0003403 0.8005 0.0008945 0.3146 0.0007361 0.2131          1
#> 4: 0.7669 0.0003510 0.8258 0.0006534 0.2298 0.0007081 0.2050         16
#> 5: 0.6084 0.0002805 0.6598 0.0004687 0.1649 0.0004327 0.1253          4
#> 6: 0.7291 0.0003411 0.8024 0.0005375 0.1891 0.0004674 0.1353          1
#>    d2b_ranked d3b_ranked d4a_ranked nat_walk_ind
#>         <int>      <int>      <int>        <num>
#> 1:         14         15         17       14.000
#> 2:         10         12         14       10.833
#> 3:          1          7         17        8.333
#> 4:         10         17         17       15.667
#> 5:          7         11         14       10.167
#> 6:          4          5         13        6.833
#>                                        region households workers_1 residents
#>                                        <char>      <int>     <int>     <int>
#> 1: Dallas-Fort Worth-Arlington, TX Metro Area        444       412      1141
#> 2: Dallas-Fort Worth-Arlington, TX Metro Area        424       395       792
#> 3: Dallas-Fort Worth-Arlington, TX Metro Area        258       463       528
#> 4: Dallas-Fort Worth-Arlington, TX Metro Area        381       431       884
#> 5: Dallas-Fort Worth-Arlington, TX Metro Area        362       579      1001
#> 6: Dallas-Fort Worth-Arlington, TX Metro Area        442       586      1090
#>    drivers vehicles white  male lowwage medwage highwage w_p_lowwag w_p_medwag
#>      <num>    <int> <int> <int>   <int>   <int>    <int>      <num>      <num>
#> 1:   660.9      648   455   687      99     122      191     0.3182     0.4091
#> 2:   671.4        0   662   384      76     107      212     0.4000     0.1600
#> 3:   383.7      343    64   198     136     189      138     0.2138     0.3396
#> 4:   620.4        0   818   441      60      69      302     0.4783     0.3439
#> 5:   660.0      770   942   484      91      84      404     0.1875     0.2812
#> 6:   646.8      595   292   609     143     237      206     0.6667     0.3333
#>    w_p_highwa gas_price logd1a logd1c logd3aao logd3apo d4bo25 d5dei_1 logd4d
#>         <num>     <int>  <num>  <num>    <num>    <num>  <int>   <int>  <int>
#> 1:     0.2727       213  1.981 0.6402   0.0000    2.630      0       0      4
#> 2:     0.4400       213  1.489 0.1904   0.5625    3.010      0       0      3
#> 3:     0.4467       213  2.698 0.0000   1.9641    1.867      0       0      4
#> 4:     0.1779       213  1.441 1.1394   1.1658    3.075      0       0      4
#> 5:     0.5312       213  1.196 0.1949   1.1908    2.867      0       0      3
#> 6:     0.0000       213  2.482 0.0575   2.7748    1.022      0       0      4
#>    up_tpercap b_c_consta b_c_male b_c_ld1c b_c_drvmve b_c_ld1a b_c_ld3apo
#>         <int>      <num>    <num>    <num>      <num>    <num>      <num>
#> 1:         11     0.9627 -0.02751 -0.08353   -0.24176 -0.01823   -0.14580
#> 2:         11     0.9627 -0.02751 -0.08353   -0.24176 -0.01823   -0.14580
#> 3:         11     0.9627 -0.02751 -0.08353   -0.24176 -0.01823   -0.14580
#> 4:         11     1.6673  0.02743 -0.08030   -0.13467 -0.02681    0.09641
#> 5:         11     1.6673  0.02743 -0.08030   -0.13467 -0.02681    0.09641
#> 6:         11     1.0913  0.16231 -0.10122   -0.08118 -0.05814   -0.20658
#>    b_c_inc1 b_c_gasp b_n_consta b_n_inc2 b_n_inc3 b_n_white b_n_male b_n_drvmve
#>       <num>    <num>      <num>    <num>    <num>     <num>    <num>      <num>
#> 1: -0.06856 0.012247      2.113   0.3289   0.2323   0.03057  0.02679    0.09340
#> 2: -0.06856 0.012247      2.113   0.3289   0.2323   0.03057  0.02679    0.09340
#> 3: -0.06856 0.012247      2.113   0.3289   0.2323   0.03057  0.02679    0.09340
#> 4: -0.15442 0.005872      2.179   0.3319   0.2304   0.03178  0.02924    0.09655
#> 5: -0.15442 0.005872      2.179   0.3319   0.2304   0.03178  0.02924    0.09655
#> 6: -0.20976 0.012036      2.113   0.3289   0.2323   0.03057  0.02679    0.09340
#>    b_n_gasp b_n_ld1a b_n_ld1c b_n_ld3aao b_n_ld3apo b_n_d4bo25 b_n_d5dei
#>       <num>    <num>    <num>      <num>      <num>      <num>     <num>
#> 1: 0.000627 -0.09136 -0.09136   -0.03438    -0.3308    -0.6490   -0.3287
#> 2: 0.000627 -0.09136 -0.09136   -0.03438    -0.3308    -0.6490   -0.3287
#> 3: 0.000627 -0.09136 -0.09136   -0.03438    -0.3308    -0.6490   -0.3287
#> 4: 0.000309 -0.09509 -0.09509   -0.03634    -0.3314    -0.6237   -0.3459
#> 5: 0.000309 -0.09509 -0.09509   -0.03634    -0.3314    -0.6237   -0.3459
#> 6: 0.000627 -0.09136 -0.09136   -0.03438    -0.3308    -0.6490   -0.3287
#>    b_n_up_tpc c_r_househ c_r_pop c_r_worker c_r_driver c_r_vehicl c_r_white
#>         <num>      <int>   <int>      <int>      <num>      <int>     <num>
#> 1:     0.0235     928341 2606868    1163871    1759309    1394052    0.2913
#> 2:     0.0235     928341 2606868    1163871    1759309    1394052    0.2913
#> 3:     0.0235     928341 2606868    1163871    1759309    1394052    0.2913
#> 4:     0.0247     928341 2606868    1163871    1759309    1394052    0.2913
#> 5:     0.0247     928341 2606868    1163871    1759309    1394052    0.2913
#> 6:     0.0235     928341 2606868    1163871    1759309    1394052    0.2913
#>    c_r_male c_r_lowwag c_r_medwag c_r_highwa c_r_drm_v non_com_vmt com_vmt_pe
#>       <num>      <num>      <num>      <num>     <num>       <num>      <num>
#> 1:   0.4931     0.2138     0.3396     0.4467    0.3935       5.808      21.69
#> 2:   0.4931     0.2138     0.3396     0.4467    0.3935       5.086      21.38
#> 3:   0.4931     0.2138     0.3396     0.4467    0.3935       6.889      25.42
#> 4:   0.4931     0.2138     0.3396     0.4467    0.3935       4.517      21.76
#> 5:   0.4931     0.2138     0.3396     0.4467    0.3935       5.912      24.23
#> 6:   0.4931     0.2138     0.3396     0.4467    0.3935       8.298      27.42
#>    vmt_per_wo vmt_tot_mi vmt_tot_ma vmt_tot_av ghg_per_wo annual_ghg slc_score
#>         <num>      <num>      <num>      <num>      <num>      <num>     <num>
#> 1:      27.50      11.44      82.64      25.66      24.50       6370     77.45
#> 2:      26.47      11.44      82.64      25.66      23.58       6131     78.90
#> 3:      32.31      11.44      82.64      25.66      28.79       7485     70.69
#> 4:      26.28      11.44      82.64      25.66      23.41       6088     79.16
#> 5:      30.14      11.44      82.64      25.66      26.85       6982     73.74
#> 6:      35.71      11.44      82.64      25.66      31.82       8274     65.91
#>    shape_leng shape_area
#>         <num>      <num>
#> 1:       3110     297836
#> 2:       3519     484945
#> 3:       1697     106706
#> 4:       2923     481828
#> 5:       3732     687685
#> 6:       3110     205127

5 Variable Inventory

This section displays all variable names in the three source datasets.

5.1 Dementia Crash Data Variables

# ================================================================
# List variables in dementia crash dataset
# ================================================================

dem_variables <- data.frame(
  variable_number = seq_along(names(dem)),
  variable_name = names(dem)
)

DT::datatable(
  dem_variables,
  rownames = FALSE,
  options = list(pageLength = 25, scrollX = TRUE),
  caption = "Variables in Dementia Crash Dataset"
)

5.2 Crash Location Data Variables

# ================================================================
# List variables in crash location dataset
# ================================================================

sld1_variables <- data.frame(
  variable_number = seq_along(names(sld1)),
  variable_name = names(sld1)
)

DT::datatable(
  sld1_variables,
  rownames = FALSE,
  options = list(pageLength = 25, scrollX = TRUE),
  caption = "Variables in CRIS Crash Location Dataset"
)

5.3 Smart Location Database Variables

# ================================================================
# List variables in Texas SLD dataset
# ================================================================

sld2_variables <- data.frame(
  variable_number = seq_along(names(sld2)),
  variable_name = names(sld2)
)

DT::datatable(
  sld2_variables,
  rownames = FALSE,
  options = list(pageLength = 25, scrollX = TRUE),
  caption = "Variables in Texas Smart Location Database"
)

5.4 Texas SLD Data

# ================================================================
# Show first few rows of Texas SLD dataset
# ================================================================

DT::datatable(
  head(sld2, 10),
  rownames = FALSE,
  options = list(scrollX = TRUE, pageLength = 10),
  caption = "First 10 Rows of Texas SLD Dataset"
)

6 Prepare Join Keys

# ================================================================
# Confirm join keys before merging
# Key 1: crash_id
# Key 2: geoid10
# ================================================================

# Check whether required fields are present
required_dem_key <- "crash_id"
required_sld1_keys <- c("crash_id", "geoid10")
required_sld2_key <- "geoid10"

key_check <- data.frame(
  dataset = c("dem", "sld1", "sld1", "sld2"),
  required_key = c(required_dem_key, required_sld1_keys, required_sld2_key),
  key_exists = c(
    required_dem_key %in% names(dem),
    required_sld1_keys %in% names(sld1),
    required_sld2_key %in% names(sld2)
  )
)

knitr::kable(key_check, caption = "Join Key Availability Check")
Table 6.1: Join Key Availability Check
dataset required_key key_exists
dem crash_id TRUE
sld1 crash_id TRUE
sld1 geoid10 TRUE
sld2 geoid10 TRUE
# Stop the script if key variables are missing
if (!all(key_check$key_exists)) {
  stop("One or more required join keys are missing. Please check variable names.")
}

# Convert join keys to character to avoid numeric/character join mismatch
dem <- dem |>
  mutate(crash_id = as.character(crash_id))

sld1 <- sld1 |>
  mutate(
    crash_id = as.character(crash_id),
    geoid10 = as.character(geoid10)
  )

sld2 <- sld2 |>
  mutate(geoid10 = as.character(geoid10))

7 Check Duplicate Keys

# ================================================================
# Check duplicate keys to understand join behavior
# ================================================================

duplicate_summary <- data.frame(
  dataset = c("dem", "sld1", "sld2"),
  key = c("crash_id", "crash_id", "geoid10"),
  total_rows = c(nrow(dem), nrow(sld1), nrow(sld2)),
  unique_keys = c(
    n_distinct(dem$crash_id),
    n_distinct(sld1$crash_id),
    n_distinct(sld2$geoid10)
  )
) |>
  mutate(duplicate_key_rows = total_rows - unique_keys)

knitr::kable(duplicate_summary, caption = "Duplicate Key Summary")
Table 7.1: Duplicate Key Summary
dataset key total_rows unique_keys duplicate_key_rows
dem crash_id 4781 4781 0
sld1 crash_id 5109746 5109746 0
sld2 geoid10 15811 15811 0

8 Merge Datasets

8.1 Join Dementia Data with Crash Location Data

# ================================================================
# Join dementia crash data with crash location block group data
# ================================================================

dem1 <- dem |>
  left_join(sld1, by = "crash_id")

cat("Rows before join:", nrow(dem), "\n")
#> Rows before join: 4781
cat("Rows after join:", nrow(dem1), "\n")
#> Rows after join: 4781
cat("Columns after join:", ncol(dem1), "\n")
#> Columns after join: 160

8.2 Join with Smart Location Database

# ================================================================
# Join merged crash file with Texas SLD data using GEOID10
# ================================================================

dem2 <- dem1 |>
  left_join(sld2, by = "geoid10")

cat("Rows before SLD join:", nrow(dem1), "\n")
#> Rows before SLD join: 4781
cat("Rows after SLD join:", nrow(dem2), "\n")
#> Rows after SLD join: 4781
cat("Columns after SLD join:", ncol(dem2), "\n")
#> Columns after SLD join: 341

9 Merge Quality Checks

# ================================================================
# Evaluate merge completeness
# ================================================================

merge_quality <- data.frame(
  item = c(
    "Original dementia crash rows",
    "Rows after crash-location join",
    "Rows after SLD join",
    "Records with missing GEOID10 after crash-location join",
    "Records with missing GEOID10 after SLD join"
  ),
  value = c(
    nrow(dem),
    nrow(dem1),
    nrow(dem2),
    sum(is.na(dem1$geoid10)),
    sum(is.na(dem2$geoid10))
  )
)

knitr::kable(merge_quality, caption = "Merge Quality Summary")
Table 9.1: Merge Quality Summary
item value
Original dementia crash rows 4781
Rows after crash-location join 4781
Rows after SLD join 4781
Records with missing GEOID10 after crash-location join 425
Records with missing GEOID10 after SLD join 425

10 Descriptive Summary

# ================================================================
# Skim final dataset to inspect missingness, variable types, and ranges
# ================================================================

skimr::skim(dem2)
Table 10.1: Data summary
Name dem2
Number of rows 4781
Number of columns 341
_______________________
Column type frequency:
character 115
logical 8
numeric 218
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
crash_id 0 1.00 8 8 0 4781 0
crash_date 0 1.00 8 10 0 2517 0
crash_time 0 1.00 7 8 0 1582 0
wthr_cond_id 0 1.00 3 28 0 9 0
light_cond_id 0 1.00 4 28 0 8 0
entr_road_id 0 1.00 10 28 0 9 0
road_type_id 876 0.82 13 26 0 3 0
road_algn_id 0 1.00 7 28 0 8 0
surf_cond_id 0 1.00 3 28 0 9 0
traffic_cntl_id 0 1.00 4 42 0 18 0
investigat_notify_time 0 1.00 7 8 0 1615 0
investigat_arrv_time 0 1.00 7 8 0 1617 0
harm_evnt_id 0 1.00 6 26 0 10 0
intrsct_relat_id 0 1.00 12 20 0 4 0
fhe_collsn_id 0 1.00 5 50 0 35 0
obj_struck_id 0 1.00 5 50 0 40 0
othr_factr_id 0 1.00 11 76 0 42 0
road_part_adj_id 0 1.00 13 28 0 6 0
road_cls_id 0 1.00 7 19 0 8 0
road_relat_id 0 1.00 6 14 0 5 0
cnty_id 0 1.00 3 13 0 205 0
city_id 0 1.00 4 23 0 466 0
onsys_fl 0 1.00 1 1 0 2 0
rural_fl 0 1.00 1 1 0 2 0
crash_sev_id 0 1.00 6 21 0 6 0
pop_group_id 0 1.00 5 21 0 9 0
day_of_week 0 1.00 3 3 0 7 0
rural_urban_type_id 2361 0.51 13 28 0 4 0
func_sys_id 3892 0.19 16 20 0 4 0
year.x 0 1.00 4 4 0 9 0
investigator_narrative 0 1.00 97 10657 0 4781 0
yr_un 0 1.00 4 4 0 9 0
unit_id 0 1.00 10 10 0 4781 0
unit_desc_id 0 1.00 13 13 0 1 0
veh_lic_plate_nbr 103 0.98 1 8 0 4653 0
vin 97 0.98 3 17 0 4662 0
veh_color_id 32 0.99 3 28 0 22 0
veh_make_id 51 0.99 3 28 0 68 0
veh_mod_id 109 0.98 1 28 0 559 0
veh_body_styl_id 0 1.00 3 28 0 14 0
emer_respndr_fl 0 1.00 1 1 0 2 0
veh_damage_description1_id 152 0.97 14 45 0 23 0
veh_damage_severity1_id 150 0.97 9 17 0 8 0
veh_cmv_fl 0 1.00 1 1 0 2 0
contrib_factr_1_id 275 0.94 4 68 0 66 0
contrib_factr_2_id 3510 0.27 12 48 0 55 0
pedestrian_action_id 0 1.00 14 32 0 2 0
pedalcyclist_action_id 0 1.00 14 32 0 2 0
pbcat_pedestrian_id 0 1.00 14 32 0 2 0
pbcat_pedalcyclist_id 0 1.00 14 32 0 2 0
e_scooter_id 0 1.00 14 32 0 2 0
autonomous_unit_id 0 1.00 2 32 0 2 0
cmv_hazmat_fl 4700 0.02 1 1 0 2 0
yr_pr 508 0.89 4 4 0 8 0
person_id 16 1.00 12 12 0 4765 0
prsn_type_id 16 1.00 6 33 0 4 0
prsn_injry_sev_id 16 1.00 6 25 0 6 0
prsn_ethnicity_id 36 0.99 5 27 0 7 0
prsn_gndr_id 16 1.00 4 7 0 3 0
prsn_ejct_id 16 1.00 2 14 0 5 0
prsn_rest_id 16 1.00 4 28 0 8 0
prsn_airbag_id 16 1.00 7 18 0 6 0
prsn_helmet_id 16 1.00 8 17 0 6 0
drvr_lic_type_id 50 0.99 5 22 0 7 0
drvr_lic_number 383 0.92 2 15 0 4367 0
drvr_lic_cls_id 50 0.99 7 18 0 10 0
drvr_dob 167 0.97 10 10 0 4212 0
drvr_state_id 272 0.94 2 2 0 39 0
drvr_zip 235 0.95 3 10 0 1327 0
other_unit_id 0 1.00 10 10 0 4781 0
other_person_id 0 1.00 12 12 0 4781 0
year_2 2022 0.58 4 4 0 9 0
unit_desc_id_2 2022 0.58 5 28 0 7 0
veh_lic_plate_nbr_2 2281 0.52 1 8 0 2497 0
vin_2 2279 0.52 7 17 0 2502 0
veh_color_id_2 2256 0.53 3 28 0 21 0
veh_make_id_2 2260 0.53 3 36 0 58 0
veh_mod_id_2 2296 0.52 1 28 0 436 0
veh_body_styl_id_2 2241 0.53 3 28 0 15 0
emer_respndr_fl_2 2241 0.53 1 1 0 2 0
veh_damage_description1_id_2 2330 0.51 14 45 0 23 0
veh_damage_severity1_id_2 2336 0.51 9 17 0 8 0
veh_cmv_fl_2 2241 0.53 1 1 0 2 0
contrib_factr_1_id_2 2098 0.56 4 50 0 44 0
contrib_factr_2_id_2 4708 0.02 17 50 0 22 0
pedestrian_action_id_2 2022 0.58 7 73 0 14 0
pedalcyclist_action_id_2 2022 0.58 14 85 0 7 0
pbcat_pedestrian_id_2 2022 0.58 14 48 0 20 0
pbcat_pedalcyclist_id_2 2022 0.58 14 48 0 10 0
e_scooter_id_2 2022 0.58 14 32 0 2 0
autonomous_unit_id_2 2022 0.58 2 32 0 3 0
cmv_hazmat_fl_2 4684 0.02 1 1 0 2 0
year_2_2 2757 0.42 4 4 0 8 0
unit_id_2 2521 0.47 10 10 0 2260 0
prsn_type_id_2 2521 0.47 6 33 0 7 0
prsn_injry_sev_id_2 2521 0.47 6 25 0 6 0
prsn_ethnicity_id_2 2531 0.47 5 27 0 7 0
prsn_gndr_id_2 2521 0.47 4 7 0 3 0
prsn_ejct_id_2 2521 0.47 2 14 0 4 0
prsn_rest_id_2 2521 0.47 4 28 0 7 0
prsn_airbag_id_2 2521 0.47 7 18 0 6 0
prsn_helmet_id_2 2521 0.47 8 17 0 6 0
drvr_lic_type_id_2 2582 0.46 5 22 0 7 0
drvr_lic_number_2 2726 0.43 5 14 0 2055 0
drvr_lic_cls_id_2 2582 0.46 7 18 0 10 0
drvr_dob_2 2572 0.46 10 10 0 2103 0
drvr_state_id_2 2615 0.45 2 2 0 28 0
drvr_zip_2 2621 0.45 2 10 0 939 0
geoid10 425 0.91 12 12 0 3237 0
geoid20.x 425 0.91 1 328 0 3237 0
cbsa_name.x 739 0.85 8 36 0 68 0
geoid20.y 425 0.91 1 328 0 3237 0
csa_name 1651 0.65 18 38 0 13 0
cbsa_name.y 739 0.85 8 36 0 68 0
region 425 0.91 10 47 0 150 0

Variable type: logical

skim_variable n_missing complete_rate mean count
secondary_crash_fl 4781 0.00 NaN :
rpt_autonomous_level_engaged_id 3803 0.20 0.05 FAL: 933, TRU: 45
rpt_autonomous_unit_id 4781 0.00 NaN :
drvr_lic_state_id 4781 0.00 NaN :
dementia_flag 0 1.00 1.00 TRU: 4781
rpt_autonomous_level_engaged_id_2 4195 0.12 0.04 FAL: 562, TRU: 24
rpt_autonomous_unit_id_2 4781 0.00 NaN :
drvr_lic_state_id_2 4781 0.00 NaN :

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
crash_speed_limit 0 1.00 43.10 18.52 -1.00 30.00 45.00 55.00 80.00 ▂▃▇▃▃
latitude.x 425 0.91 31.00 1.78 25.90 29.59 30.51 32.69 36.38 ▁▇▅▇▁
longitude.x 425 0.91 -97.41 2.29 -106.61 -98.42 -97.17 -95.65 -93.70 ▁▁▁▇▅
adt_curnt_amt 2382 0.50 48667.46 59793.28 22.00 8561.50 23501.00 58474.50 337375.00 ▇▁▁▁▁
adt_curnt_year 2382 0.50 2019.69 1.41 2019.00 2019.00 2019.00 2019.00 2023.00 ▇▁▁▁▁
tot_injry_cnt 0 1.00 0.80 0.86 0.00 0.00 1.00 1.00 9.00 ▇▁▁▁▁
death_cnt 0 1.00 0.01 0.12 0.00 0.00 0.00 0.00 3.00 ▇▁▁▁▁
sus_serious_injry_cnt 0 1.00 0.08 0.31 0.00 0.00 0.00 0.00 4.00 ▇▁▁▁▁
unit_nbr_un 0 1.00 1.00 0.00 1.00 1.00 1.00 1.00 1.00 ▁▁▇▁▁
veh_mod_year 89 0.98 2010.95 7.11 1957.00 2006.00 2012.00 2016.00 2026.00 ▁▁▁▇▇
crash_id_pr 16 1.00 18295084.81 1619775.58 15517460.00 16925649.00 18215897.00 19654909.00 21221960.00 ▇▇▇▇▇
unit_nbr_pr 16 1.00 1.00 0.00 1.00 1.00 1.00 1.00 1.00 ▁▁▇▁▁
prsn_nbr 16 1.00 1.00 0.00 1.00 1.00 1.00 1.00 1.00 ▁▁▇▁▁
prsn_occpnt_pos_id 16 1.00 1.02 0.48 1.00 1.00 1.00 1.00 12.00 ▇▁▁▁▁
prsn_age 175 0.96 54.73 21.17 1.00 36.00 57.00 73.00 99.00 ▁▆▅▇▃
prsn_alc_spec_type_id 16 1.00 3.85 0.68 1.00 4.00 4.00 4.00 6.00 ▁▁▇▁▁
prsn_alc_rslt_id 4503 0.06 1.28 0.45 1.00 1.00 1.00 2.00 2.00 ▇▁▁▁▃
prsn_bac_test_rslt 4503 0.06 0.15 0.10 0.00 0.04 0.17 0.22 0.44 ▆▆▇▂▁
prsn_drg_spec_type_id 16 1.00 3.94 0.48 2.00 4.00 4.00 4.00 6.00 ▁▁▇▁▁
prsn_drg_rslt_id 16 1.00 92.16 21.06 0.00 97.00 97.00 97.00 97.00 ▁▁▁▁▇
num_un 0 1.00 1.72 0.76 1.00 1.00 2.00 2.00 8.00 ▇▁▁▁▁
num_pr 0 1.00 1.69 0.70 1.00 1.00 2.00 2.00 6.00 ▇▁▁▁▁
othr_unit_nbr 0 1.00 2.00 0.00 2.00 2.00 2.00 2.00 2.00 ▁▁▇▁▁
othr_prsn_nbr 0 1.00 1.00 0.00 1.00 1.00 1.00 1.00 1.00 ▁▁▇▁▁
crash_id_2 2022 0.58 18314694.84 1633073.52 15517460.00 16938856.50 18253017.00 19707724.00 21216886.00 ▇▇▇▇▇
unit_nbr 2022 0.58 2.00 0.00 2.00 2.00 2.00 2.00 2.00 ▁▁▇▁▁
veh_mod_year_2 2278 0.52 2012.31 6.94 1970.00 2007.00 2014.00 2017.00 2026.00 ▁▁▂▇▇
crash_id_2_2 2521 0.47 18308145.64 1629397.74 15517460.00 16926969.00 18258527.50 19681260.75 21216501.00 ▇▇▇▇▇
unit_nbr_2 2521 0.47 2.00 0.00 2.00 2.00 2.00 2.00 2.00 ▁▁▇▁▁
prsn_nbr_2 2521 0.47 1.00 0.00 1.00 1.00 1.00 1.00 1.00 ▁▁▇▁▁
prsn_occpnt_pos_id_2 2521 0.47 1.87 3.94 1.00 1.00 1.00 1.00 98.00 ▇▁▁▁▁
prsn_age_2 2567 0.46 43.26 17.41 9.00 29.00 41.00 56.00 112.00 ▆▇▆▂▁
prsn_alc_spec_type_id_2 2521 0.47 3.98 0.25 1.00 4.00 4.00 4.00 6.00 ▁▁▇▁▁
prsn_alc_rslt_id_2 4762 0.00 1.53 0.51 1.00 1.00 2.00 2.00 2.00 ▇▁▁▁▇
prsn_bac_test_rslt_2 4762 0.00 0.12 0.14 0.00 0.00 0.04 0.24 0.50 ▇▂▃▁▁
prsn_drg_spec_type_id_2 2521 0.47 3.99 0.20 2.00 4.00 4.00 4.00 6.00 ▁▁▇▁▁
prsn_drg_rslt_id_2 2521 0.47 96.11 9.21 0.00 97.00 97.00 97.00 97.00 ▁▁▁▁▇
latitude.y 425 0.91 31.00 1.78 25.90 29.59 30.51 32.69 36.38 ▁▇▅▇▁
longitude.y 425 0.91 -97.41 2.29 -106.61 -98.42 -97.17 -95.65 -93.70 ▁▁▁▇▅
year.y 425 0.91 2020.81 2.54 2017.00 2019.00 2021.00 2023.00 2025.00 ▇▇▅▇▆
cbsa.x 739 0.85 27507.67 10999.52 10180.00 19100.00 26420.00 41700.00 48660.00 ▅▇▇▁▇
v1 425 0.91 7820.30 4648.79 33.00 3543.75 7715.00 11960.50 15809.00 ▇▆▇▇▇
statefp 425 0.91 48.00 0.00 48.00 48.00 48.00 48.00 48.00 ▁▁▇▁▁
countyfp 425 0.91 209.75 153.56 1.00 81.50 201.00 339.00 507.00 ▇▇▂▂▅
tractce 425 0.91 267419.37 336963.30 100.00 13500.00 121111.50 451200.00 980100.00 ▇▁▁▁▂
blkgrpce 425 0.91 2.03 1.11 1.00 1.00 2.00 3.00 8.00 ▇▂▁▁▁
csa 1651 0.65 312.95 118.39 108.00 206.00 288.00 484.00 544.00 ▁▇▆▁▆
cbsa.y 739 0.85 27507.67 10999.52 10180.00 19100.00 26420.00 41700.00 48660.00 ▅▇▇▁▇
cbsa_pop 425 0.91 3396712.03 3005073.61 0.00 284503.00 2426204.00 6779104.00 7189384.00 ▇▅▁▁▇
cbsa_emp 425 0.91 1561829.96 1437875.97 0.00 114358.00 979988.00 2975382.00 3545715.00 ▇▅▁▁▇
cbsa_wrk 425 0.91 1511979.40 1367026.04 0.00 114455.00 1019742.00 2886903.00 3364458.00 ▇▅▁▁▇
ac_total 425 0.91 19691.33 96207.13 30.45 273.99 864.30 6208.38 1793264.49 ▇▁▁▁▁
ac_water 425 0.91 407.11 4854.90 0.00 0.00 1.38 49.23 149575.59 ▇▁▁▁▁
ac_land 425 0.91 19284.22 95744.23 30.45 273.84 845.44 6099.79 1793251.31 ▇▁▁▁▁
ac_unpr 425 0.91 18828.49 93015.31 30.45 266.50 808.30 5841.58 1793218.58 ▇▁▁▁▁
tot_pop 425 0.91 2268.36 2450.24 0.00 1127.75 1699.00 2614.75 55407.00 ▇▁▁▁▁
count_hu 425 0.91 872.31 800.07 0.00 470.75 691.00 1034.00 16056.00 ▇▁▁▁▁
hh 425 0.91 777.40 759.58 0.00 406.00 602.00 908.00 15407.00 ▇▁▁▁▁
p_wrk_age 425 0.91 0.60 0.10 0.00 0.54 0.59 0.65 0.99 ▁▁▇▇▁
auto_own0 425 0.91 36.59 51.40 0.00 0.00 20.00 49.00 608.00 ▇▁▁▁▁
pct_ao0 425 0.91 0.06 0.08 0.00 0.00 0.03 0.08 0.70 ▇▁▁▁▁
auto_own1 425 0.91 250.14 235.84 0.00 110.00 183.00 308.00 2848.00 ▇▁▁▁▁
pct_ao1 425 0.91 0.33 0.15 0.00 0.22 0.31 0.43 1.00 ▃▇▅▁▁
auto_own2p 425 0.91 490.67 591.69 0.00 222.00 361.00 574.00 13158.00 ▇▁▁▁▁
pct_ao2p 425 0.91 0.61 0.19 0.00 0.48 0.64 0.75 1.00 ▁▂▅▇▃
workers 425 0.91 945.43 911.69 10.00 486.00 726.00 1110.00 18918.00 ▇▁▁▁▁
r_low_wage_w 425 0.91 203.66 168.31 2.00 113.00 164.00 242.00 3525.00 ▇▁▁▁▁
r_med_wage_w 425 0.91 297.67 231.98 7.00 168.00 243.50 364.00 4710.00 ▇▁▁▁▁
r_hi_wage_wk 425 0.91 444.10 549.45 1.00 179.00 297.00 532.00 10683.00 ▇▁▁▁▁
r_pctlowwa 425 0.91 0.23 0.05 0.07 0.19 0.22 0.26 0.47 ▁▇▆▁▁
tot_emp 425 0.91 1662.86 4337.89 0.00 166.00 487.00 1429.75 82048.00 ▇▁▁▁▁
e5_ret 425 0.91 187.64 408.87 0.00 7.00 37.00 173.25 4489.00 ▇▁▁▁▁
e5_off 425 0.91 219.89 1153.03 0.00 3.00 21.00 87.25 23140.00 ▇▁▁▁▁
e5_ind 425 0.91 488.87 1720.04 0.00 20.00 83.00 299.25 31734.00 ▇▁▁▁▁
e5_svc 425 0.91 570.50 1957.94 0.00 28.00 114.00 379.25 44114.00 ▇▁▁▁▁
e5_ent 425 0.91 195.96 512.71 0.00 4.00 45.00 180.00 9326.00 ▇▁▁▁▁
e8_ret 425 0.91 187.64 408.87 0.00 7.00 37.00 173.25 4489.00 ▇▁▁▁▁
e8_off 425 0.91 163.20 763.20 0.00 2.00 17.00 66.00 17899.00 ▇▁▁▁▁
e8_ind 425 0.91 488.87 1720.04 0.00 20.00 83.00 299.25 31734.00 ▇▁▁▁▁
e8_svc 425 0.91 262.12 959.63 0.00 12.00 46.00 167.00 24448.00 ▇▁▁▁▁
e8_ent 425 0.91 195.96 512.71 0.00 4.00 45.00 180.00 9326.00 ▇▁▁▁▁
e8_ed 425 0.91 127.93 985.73 0.00 0.00 0.00 10.00 26502.00 ▇▁▁▁▁
e8_hlth 425 0.91 180.45 835.21 0.00 1.00 23.00 107.00 20052.00 ▇▁▁▁▁
e8_pub 425 0.91 56.69 640.32 0.00 0.00 0.00 0.00 18592.00 ▇▁▁▁▁
e_low_wage_w 425 0.91 342.78 696.00 0.00 39.00 114.00 342.00 10274.00 ▇▁▁▁▁
e_med_wage_w 425 0.91 534.37 1212.65 0.00 61.00 175.00 508.00 16102.00 ▇▁▁▁▁
e_hi_wage_wk 425 0.91 785.70 2611.41 0.00 45.00 158.00 496.00 55672.00 ▇▁▁▁▁
e_pct_low_wa 425 0.91 0.27 0.14 0.00 0.17 0.25 0.35 1.00 ▆▇▂▁▁
d1a 425 0.91 1.63 2.11 0.00 0.13 1.01 2.41 26.68 ▇▁▁▁▁
d1b 425 0.91 4.05 4.81 0.00 0.34 2.61 6.24 55.90 ▇▁▁▁▁
d1c 425 0.91 3.10 10.76 0.00 0.07 0.55 2.56 309.61 ▇▁▁▁▁
d1c5_ret 425 0.91 0.36 0.93 0.00 0.00 0.04 0.29 14.03 ▇▁▁▁▁
d1c5_off 425 0.91 0.51 3.85 0.00 0.00 0.02 0.15 170.48 ▇▁▁▁▁
d1c5_ind 425 0.91 0.51 2.02 0.00 0.01 0.06 0.28 80.31 ▇▁▁▁▁
d1c5_svc 425 0.91 1.31 5.83 0.00 0.01 0.13 0.63 175.27 ▇▁▁▁▁
d1c5_ent 425 0.91 0.40 1.24 0.00 0.00 0.04 0.32 26.65 ▇▁▁▁▁
d1c8_ret 425 0.91 0.36 0.93 0.00 0.00 0.04 0.29 14.03 ▇▁▁▁▁
d1c8_off 425 0.91 0.35 2.09 0.00 0.00 0.01 0.13 83.21 ▇▁▁▁▁
d1c8_ind 425 0.91 0.51 2.02 0.00 0.01 0.06 0.28 80.31 ▇▁▁▁▁
d1c8_svc 425 0.91 0.56 2.58 0.00 0.00 0.05 0.27 86.07 ▇▁▁▁▁
d1c8_ent 425 0.91 0.40 1.24 0.00 0.00 0.04 0.32 26.65 ▇▁▁▁▁
d1c8_ed 425 0.91 0.32 3.91 0.00 0.00 0.00 0.01 174.77 ▇▁▁▁▁
d1c8_hlth 425 0.91 0.42 2.29 0.00 0.00 0.02 0.18 59.06 ▇▁▁▁▁
d1c8_pub 425 0.91 0.16 2.24 0.00 0.00 0.00 0.00 87.27 ▇▁▁▁▁
d1d 425 0.91 4.73 11.42 0.00 0.26 2.35 5.16 320.30 ▇▁▁▁▁
d1_flag 425 0.91 0.00 0.00 0.00 0.00 0.00 0.00 0.00 ▁▁▇▁▁
d2a_jphh 425 0.91 3.07 18.20 0.00 0.26 0.73 2.07 675.00 ▇▁▁▁▁
d2b_e5mix 425 0.91 0.68 0.21 0.00 0.57 0.73 0.84 1.00 ▁▂▃▇▇
d2b_e5mixa 425 0.91 0.63 0.23 0.00 0.49 0.68 0.81 0.99 ▁▂▅▇▆
d2b_e8mix 425 0.91 0.68 0.20 0.00 0.58 0.73 0.83 1.00 ▁▁▃▇▆
d2b_e8mixa 425 0.91 0.56 0.20 0.00 0.44 0.60 0.72 0.95 ▁▂▅▇▃
d2a_ephhm 425 0.91 0.58 0.22 0.00 0.43 0.60 0.75 1.00 ▂▃▆▇▅
d2c_trpmx1 425 0.91 0.55 0.20 0.00 0.41 0.59 0.71 0.92 ▂▃▅▇▅
d2c_trpmx2 425 0.91 0.56 0.22 0.00 0.42 0.61 0.75 0.98 ▂▃▆▇▃
d2c_tripeq 425 0.91 0.43 0.28 0.00 0.23 0.44 0.61 1.00 ▆▃▇▃▂
d2r_jobpop 425 0.91 0.39 0.30 0.00 0.12 0.33 0.63 1.00 ▇▅▃▃▃
d2r_wrkemp 425 0.91 0.47 0.30 0.00 0.21 0.46 0.74 1.00 ▇▆▆▆▆
d2a_wrkemp 425 0.91 5.94 26.29 0.00 0.58 1.58 4.56 956.00 ▇▁▁▁▁
d2c_wremlx 425 0.91 0.38 0.31 0.00 0.03 0.41 0.61 1.00 ▇▂▆▃▂
d3a 425 0.91 14.31 10.16 0.27 4.53 13.48 21.75 55.84 ▇▆▃▁▁
d3aao 425 0.91 2.31 3.32 0.00 0.23 0.88 3.20 27.79 ▇▁▁▁▁
d3amm 425 0.91 2.51 2.49 0.00 0.88 1.64 3.41 20.12 ▇▂▁▁▁
d3apo 425 0.91 9.48 7.59 0.01 2.41 8.23 15.09 53.88 ▇▅▁▁▁
d3b 425 0.91 59.17 61.48 0.00 8.01 43.01 89.48 620.87 ▇▁▁▁▁
d3bao 425 0.91 5.15 8.71 0.00 0.28 1.76 6.46 111.59 ▇▁▁▁▁
d3bmm3 425 0.91 9.48 12.05 0.00 1.59 4.93 12.80 137.28 ▇▁▁▁▁
d3bmm4 425 0.91 5.56 9.84 0.00 0.12 1.54 6.71 103.80 ▇▁▁▁▁
d3bpo3 425 0.91 47.14 52.19 0.00 6.11 32.57 69.48 542.25 ▇▁▁▁▁
d3bpo4 425 0.91 15.85 25.94 0.00 0.69 6.01 18.99 320.88 ▇▁▁▁▁
d4a 425 0.91 -69593.69 46167.65 -99999.00 -99999.00 -99999.00 241.74 1207.00 ▇▁▁▁▃
d4b025 425 0.91 0.01 0.05 0.00 0.00 0.00 0.00 0.99 ▇▁▁▁▁
d4b050 425 0.91 0.02 0.10 0.00 0.00 0.00 0.00 1.00 ▇▁▁▁▁
d4c 425 0.91 -62368.95 48455.16 -99999.00 -99999.00 -99999.00 4.00 144.00 ▇▁▁▁▅
d4d 425 0.91 -62361.93 48464.20 -99999.00 -99999.00 -99999.00 5.67 690.02 ▇▁▁▁▅
d4e 425 0.91 -62373.11 48449.80 -99999.00 -99999.00 -99999.00 0.00 0.32 ▇▁▁▁▅
d5ar 425 0.91 124026.09 124896.61 136.00 16730.50 90405.00 192114.50 525126.00 ▇▃▂▁▁
d5ae 425 0.91 100414.35 91307.51 282.00 15467.00 82983.00 157428.00 345410.00 ▇▃▂▂▁
d5br 425 0.91 -27988.97 127442.16 -99999.00 -99999.00 -99999.00 24834.25 732888.00 ▇▂▁▁▁
d5be 425 0.91 -49346.08 82593.26 -99999.00 -99999.00 -99999.00 14763.25 388536.00 ▇▂▁▁▁
d5cr 425 0.91 0.00 0.01 0.00 0.00 0.00 0.00 0.22 ▇▁▁▁▁
d5cri 425 0.91 0.45 0.28 0.00 0.22 0.45 0.68 1.00 ▇▇▇▆▅
d5ce 425 0.91 0.00 0.01 0.00 0.00 0.00 0.00 0.27 ▇▁▁▁▁
d5cei 425 0.91 0.53 0.29 0.00 0.29 0.57 0.78 1.00 ▆▅▆▇▆
d5dr 425 0.91 -69742.19 45941.93 -99999.00 -99999.00 -99999.00 0.00 0.01 ▇▁▁▁▃
d5dri 425 0.91 -69742.09 45942.08 -99999.00 -99999.00 -99999.00 0.07 1.00 ▇▁▁▁▃
d5de 425 0.91 -69742.19 45941.93 -99999.00 -99999.00 -99999.00 0.00 0.01 ▇▁▁▁▃
d5dei 425 0.91 -69742.09 45942.07 -99999.00 -99999.00 -99999.00 0.07 1.00 ▇▁▁▁▃
d2a_ranked 425 0.91 12.53 5.63 1.00 8.00 13.00 18.00 20.00 ▃▃▅▆▇
d2b_ranked 425 0.91 11.30 5.60 1.00 6.00 12.00 16.00 20.00 ▅▇▇▇▇
d3b_ranked 425 0.91 9.18 5.39 1.00 5.00 9.00 13.00 20.00 ▇▇▇▅▃
d4a_ranked 425 0.91 5.58 7.05 1.00 1.00 1.00 14.00 20.00 ▇▁▁▂▂
nat_walk_ind 425 0.91 8.89 4.14 1.00 5.50 8.33 12.00 19.50 ▅▇▆▅▂
households 425 0.91 801.13 836.60 0.00 405.00 608.00 920.00 16932.00 ▇▁▁▁▁
workers_1 425 0.91 945.43 911.69 10.00 486.00 726.00 1110.00 18918.00 ▇▁▁▁▁
residents 425 0.91 2337.76 2731.40 0.00 1144.75 1712.00 2638.75 59947.00 ▇▁▁▁▁
drivers 425 0.91 1586.33 1763.90 0.00 786.72 1174.80 1830.40 38600.32 ▇▁▁▁▁
vehicles 425 0.91 1402.47 1805.00 0.00 600.00 1040.00 1665.00 37222.00 ▇▁▁▁▁
white 425 0.91 1039.15 1217.55 0.00 323.75 757.00 1333.00 23014.00 ▇▁▁▁▁
male 425 0.91 1164.47 1349.42 0.00 563.75 849.00 1325.00 28936.00 ▇▁▁▁▁
lowwage 425 0.91 203.66 168.31 2.00 113.00 164.00 242.00 3525.00 ▇▁▁▁▁
medwage 425 0.91 297.67 231.98 7.00 168.00 243.50 364.00 4710.00 ▇▁▁▁▁
highwage 425 0.91 444.10 549.45 1.00 179.00 297.00 532.00 10683.00 ▇▁▁▁▁
w_p_lowwag 425 0.91 0.27 0.14 0.00 0.17 0.25 0.35 1.00 ▆▇▂▁▁
w_p_medwag 425 0.91 0.38 0.11 0.00 0.31 0.37 0.44 1.00 ▁▇▅▁▁
w_p_highwa 425 0.91 0.36 0.17 0.00 0.22 0.33 0.47 1.00 ▃▇▅▂▁
gas_price 425 0.91 213.00 0.00 213.00 213.00 213.00 213.00 213.00 ▁▁▇▁▁
logd1a 425 0.91 0.75 0.63 0.00 0.12 0.70 1.23 3.32 ▇▅▃▁▁
logd1c 425 0.91 0.78 0.89 0.00 0.06 0.44 1.27 5.74 ▇▂▁▁▁
logd3aao 425 0.91 0.86 0.77 0.00 0.21 0.63 1.44 3.36 ▇▃▃▁▁
logd3apo 425 0.91 2.00 0.93 0.01 1.23 2.22 2.78 4.01 ▃▃▅▇▁
d4bo25 425 0.91 0.00 0.05 0.00 0.00 0.00 0.00 1.00 ▇▁▁▁▁
d5dei_1 425 0.91 0.07 0.26 0.00 0.00 0.00 0.00 1.00 ▇▁▁▁▁
logd4d 425 0.91 0.91 1.48 0.00 0.00 0.00 2.00 7.00 ▇▁▂▁▁
up_tpercap 425 0.91 9.88 6.72 0.00 1.00 11.00 14.00 18.00 ▅▁▁▇▅
b_c_consta 425 0.91 3.64 1.93 0.00 2.13 3.72 5.25 9.45 ▆▇▇▃▁
b_c_male 425 0.91 0.02 0.12 -0.29 -0.06 0.00 0.09 0.43 ▁▇▇▂▁
b_c_ld1c 425 0.91 -0.01 0.11 -0.49 -0.05 0.00 0.06 0.33 ▁▁▇▇▁
b_c_drvmve 425 0.91 -0.25 0.22 -1.17 -0.38 -0.26 -0.12 0.58 ▁▂▇▃▁
b_c_ld1a 425 0.91 -0.01 0.19 -0.72 -0.11 -0.02 0.09 1.25 ▁▇▃▁▁
b_c_ld3apo 425 0.91 -0.20 0.21 -1.01 -0.30 -0.19 -0.11 0.58 ▁▂▇▂▁
b_c_inc1 425 0.91 -0.27 0.19 -0.93 -0.38 -0.26 -0.13 0.25 ▁▂▇▇▁
b_c_gasp 425 0.91 0.00 0.01 -0.03 -0.01 0.00 0.00 0.02 ▁▁▇▇▅
b_n_consta 425 0.91 2.76 0.49 1.66 2.38 2.76 3.20 3.70 ▂▆▅▇▂
b_n_inc2 425 0.91 0.05 0.15 -0.19 -0.09 0.01 0.16 0.35 ▇▇▅▂▅
b_n_inc3 425 0.91 0.04 0.09 -0.11 -0.04 0.00 0.11 0.24 ▅▇▃▅▃
b_n_white 425 0.91 -0.04 0.05 -0.13 -0.07 -0.04 0.00 0.07 ▅▅▇▃▃
b_n_male 425 0.91 0.04 0.01 0.01 0.03 0.03 0.05 0.06 ▃▇▂▃▃
b_n_drvmve 425 0.91 -0.03 0.07 -0.14 -0.08 -0.07 0.03 0.15 ▇▆▃▅▁
b_n_gasp 425 0.91 0.00 0.00 -0.01 0.00 0.00 0.00 0.00 ▃▇▆▂▂
b_n_ld1a 425 0.91 -0.13 0.03 -0.19 -0.15 -0.14 -0.10 -0.07 ▁▇▃▃▃
b_n_ld1c 425 0.91 -0.13 0.03 -0.19 -0.15 -0.14 -0.10 -0.07 ▁▇▃▃▃
b_n_ld3aao 425 0.91 0.04 0.04 -0.05 0.02 0.04 0.08 0.10 ▃▂▇▃▇
b_n_ld3apo 425 0.91 -0.22 0.06 -0.36 -0.26 -0.22 -0.18 -0.14 ▃▂▅▇▇
b_n_d4bo25 425 0.91 -0.90 0.15 -1.09 -1.01 -0.96 -0.74 -0.57 ▇▃▂▂▃
b_n_d5dei 425 0.91 -0.44 0.09 -0.66 -0.51 -0.44 -0.38 -0.18 ▂▃▇▂▁
b_n_up_tpc 425 0.91 0.01 0.01 0.00 0.01 0.01 0.01 0.03 ▃▇▅▂▂
c_r_househ 425 0.91 457084.48 498221.68 489.00 47632.00 268310.00 636245.00 1605368.00 ▇▃▂▁▂
c_r_pop 425 0.91 1334381.15 1442142.11 1252.00 131596.00 836062.00 1952843.00 4646630.00 ▇▁▅▁▂
c_r_worker 425 0.91 568742.74 608684.62 477.00 53813.00 318862.00 807576.00 1939120.00 ▇▂▃▁▂
c_r_driver 425 0.91 902594.21 971562.14 837.76 91582.48 556691.52 1326126.56 3127996.96 ▇▁▅▁▂
c_r_vehicl 425 0.91 738484.40 798251.07 1080.00 77872.00 457252.00 1031655.00 2598974.00 ▇▃▂▁▂
c_r_white 425 0.91 0.45 0.19 0.01 0.29 0.47 0.59 0.90 ▂▇▅▆▂
c_r_male 425 0.91 0.50 0.01 0.47 0.49 0.49 0.50 0.63 ▇▂▁▁▁
c_r_lowwag 425 0.91 0.23 0.03 0.18 0.21 0.22 0.24 0.39 ▇▆▂▁▁
c_r_medwag 425 0.91 0.34 0.05 0.23 0.31 0.34 0.36 0.47 ▃▆▇▃▁
c_r_highwa 425 0.91 0.44 0.08 0.22 0.39 0.43 0.48 0.59 ▁▃▇▇▃
c_r_drm_v 425 0.91 0.32 0.17 -0.50 0.24 0.33 0.39 1.31 ▁▂▇▁▁
non_com_vmt 425 0.91 6.93 2.44 1.04 5.02 6.54 8.90 13.72 ▁▇▆▅▁
com_vmt_pe 425 0.91 19.62 5.97 6.09 15.63 18.59 22.40 70.99 ▇▆▁▁▁
vmt_per_wo 425 0.91 26.55 7.53 10.57 21.04 25.36 30.91 82.54 ▇▇▁▁▁
vmt_tot_mi 425 0.91 12.54 3.10 6.98 10.99 11.74 13.47 30.99 ▇▆▁▁▁
vmt_tot_ma 425 0.91 57.81 20.28 16.44 38.98 49.42 82.54 82.64 ▁▅▃▁▇
vmt_tot_av 425 0.91 25.11 2.77 13.43 24.04 25.66 26.73 44.46 ▁▇▅▁▁
ghg_per_wo 425 0.91 23.65 6.71 9.42 18.74 22.60 27.54 73.54 ▇▇▁▁▁
annual_ghg 425 0.91 6150.02 1744.55 2449.43 4873.28 5875.51 7160.57 19121.66 ▇▇▁▁▁
slc_score 425 0.91 62.96 24.21 0.00 50.58 71.28 80.71 100.00 ▂▂▃▇▆
shape_leng 425 0.91 26258.61 44597.83 1551.05 5050.43 9601.57 26456.59 536969.73 ▇▁▁▁▁
shape_area 425 0.91 79689727.74 389344957.54 123232.95 1108835.66 3497790.94 25124965.70 7257243356.04 ▇▁▁▁▁

11 Optional: Save Final Integrated Dataset

# ================================================================
# Save final merged dataset
# Change eval=TRUE in the chunk header if you want this to run
# ================================================================

output_file <- file.path(
  cris_data_dir,
  "dementia_crashes_with_blockgroup_and_sld.csv"
)

data.table::fwrite(dem2, output_file)

cat("Saved final dataset to:", output_file, "\n")

12 Session Information

# ================================================================
# Record R session information for reproducibility
# ================================================================

sessionInfo()
#> R version 4.6.0 (2026-04-24 ucrt)
#> Platform: x86_64-w64-mingw32/x64
#> Running under: Windows 11 x64 (build 26200)
#> 
#> Matrix products: default
#>   LAPACK version 3.12.1
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.utf8 
#> [2] LC_CTYPE=English_United States.utf8   
#> [3] LC_MONETARY=English_United States.utf8
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.utf8    
#> 
#> time zone: America/Chicago
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] DT_0.34.0         knitr_1.51        skimr_2.2.2       janitor_2.2.1    
#> [5] dplyr_1.2.1       data.table_1.18.4 readxl_1.4.5     
#> 
#> loaded via a namespace (and not attached):
#>  [1] tidyr_1.3.2       sass_0.4.10       utf8_1.2.6        generics_0.1.4   
#>  [5] stringi_1.8.7     hms_1.1.4         digest_0.6.39     magrittr_2.0.5   
#>  [9] evaluate_1.0.5    timechange_0.4.0  bookdown_0.46     fastmap_1.2.0    
#> [13] cellranger_1.1.0  jsonlite_2.0.0    purrr_1.2.2       crosstalk_1.2.2  
#> [17] jquerylib_0.1.4   cli_3.6.6         rlang_1.2.0       bit64_4.8.0      
#> [21] base64enc_0.1-6   withr_3.0.2       repr_1.1.7        cachem_1.1.0     
#> [25] yaml_2.3.12       otel_0.2.0        tools_4.6.0       forcats_1.0.1    
#> [29] vctrs_0.7.3       R6_2.6.1          lifecycle_1.0.5   lubridate_1.9.5  
#> [33] snakecase_0.11.1  stringr_1.6.0     htmlwidgets_1.6.4 bit_4.6.0        
#> [37] pkgconfig_2.0.3   pillar_1.11.1     bslib_0.10.0      glue_1.8.1       
#> [41] rmdformats_1.0.4  haven_2.5.5       xfun_0.57         tibble_3.3.1     
#> [45] tidyselect_1.2.1  rstudioapi_0.18.0 htmltools_0.5.9   rmarkdown_2.31   
#> [49] compiler_4.6.0