Add Selected Mechanisms
matrix_mechanism(data, inj_col, ...)
data | input data |
---|---|
inj_col | ecode and diagnosis column indices |
... | keyword list |
return the input with additional mechanism variables
library(dplyr) library(purrr) dat <- data.frame( d1 = c("T63023", "X92821", "X99100", "T360x"), d2 = c("T65823", "Y030x0", "T17200", "V0100x") ) dat %>% matrix_mechanism(inj_col = c(1, 2), "firearm", "fall")#> d1 d2 Fall Firearm #> 1 T63023 T65823 0 0 #> 2 X92821 Y030x0 0 0 #> 3 X99100 T17200 0 0 #> 4 T360x V0100x 0 0