View source: R/chars_functions.R
chars_injury_matrix_count | R Documentation |
Generate hospitalization counts for an injury matrix
specifying the intent and mechanism of injury. Needs line-level CHARS data
with columns beginning with mechanism_
and intent_
. Covers both ICD9-cm
(2012-2015) and ICD10-cm (2016+).
chars_injury_matrix_count(
ph.data = NULL,
intent = "*",
mechanism = "*",
group_by = NULL,
def = "narrow",
primary_ecode = T,
kingco = T
)
ph.data |
a data.table or data.frame. Must contain CHARS data structured
with one person per row and predetermined The default is |
intent |
a character vector. It specifies the intent of the injury related hospitalization that you want returned (e.g., "assault", "intentional", "unintentional", etc.). "none" will ignore the intent and only return the mechanism of the injury leading to hospitalization. NOTE
You do not have to type the entire keyword for the intent, a
partial string match is sufficient and is case insensitive. E.g.,
The default is |
mechanism |
a character vector. It specifies the mechanism of the injury related hospitalization that you want returned (e.g., "cut_pierce", "drowning", "fall", "firearm", etc.). "none" will ignore the mechanism and only return the intent of the injury leading to hospitalization. To see the complete list of mechanisms, type
NOTE
You do not have to type the entire keyword for the mechanism, a
partial string match is sufficient and is case insensitive. E.g.,
The default is |
group_by |
a character vector of indeterminate length. This is used to
specify all the variables by which you want to group (a.k.a. stratify) the
results. For example, if you specified The default is |
def |
a character vector of length one, limited to 'narrow' or 'broad'. It specifies whether you want to use the CDC's recommended 'narrow' approach, which requires that the principal diagnosis of an injury hospitalization be a nature-of-injury ICD10-CM code. Or, alternatively, the 'broad' definition that searches all available diagnosis fields on the hospital discharge record (there can be a maximum of 54 diagnosis fields in CHARS data). NOTE
ph.data must contain the columns named The default is |
primary_ecode |
a logical vector of length one. It specifies whether you
want to limit the analysis to using just the primary ecode (i.e., the
As of RADS 1.1.7.7, the only valid argument is TRUE (T). Those wanting to perform
an analysis with other ecodes would need to perform a custom analysis in SQL using
the The default is |
kingco |
a logical vector of length one. It specifies whether you want to
limit the analysis to King County. Note that this only works when you have
the column The default is |
Since the injury analysis uses many columns, we suggest that you obtain ph.data with get_data_chars(cols = NA), rather than trying to specify the columns of interest.
This function will only count injuries where the type of injury (from ICD10-CM codes) AND the corresponding external cause information (from an ecode) is present. To examine injuries that do not have an external cause, please examine the analytic data directly.
See Jeremy Whitehurst's documentation for the CHARS ETL to understand exactly which codes are mapped to which intents and mechanisms.
The function returns a data.table with a minimum of three columns:
mechanism
, intent
, & hospitalizations
. Any
group_by
variables would also have their own columns.
The function default is to return the matrix of all intents and mechanisms of injury related hospitalizations. You can choose to only return the intent or only return the mechanism. If you set both to "none", you will receive a summary of all injury hospitalizations without regard to the intent or mechanism.
# example: 2019 King County hospitalizations due to intentional injury, by sex
blah = get_data_chars(year = 2019, kingco = TRUE)
myresult <- chars_injury_matrix_count(ph.data = blah,
intent = '^intentional',
mechanism = 'none',
group_by = c('chi_sex'))
print(myresult)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.