# Packages
library(dplyr)
library(traumar)
# Create synthetic test data for Indicators 5a–5d
test_data <- tibble::tibble(
id = as.character(1:10),
trauma_level = rep(c("I", "II", "III", "IV", "V"), each = 2),
bac = c(0.08, NA, 0, 0.02, NA, 0.15, NA, NA, 0, 0),
drug = c(
"opioid", "none", "cocaine", "none", NA,
"benzodiazepine", "alcohol", "thc", "none", NA
)
)
# Run the indicator function
traumar::seqic_indicator_5(
data = test_data,
level = trauma_level,
unique_incident_id = id,
blood_alcohol_content = bac,
drug_screen = drug
) |>
tidyr::pivot_longer(cols = -1, names_to = "Indicator", values_to =
"Values")
Run the code above in your browser using DataLab