death_other_count | R Documentation |
Generate death counts for causes of death that are NOT included in the NCHS
113 Causes of death (see ?death_113_count
) or the CDC death injury
matrix (see ?death_injury_matrix_count
).
Needs line-level death data with a properly formatted ICD10 column.
Use the cause
argument to specify the cause(s) for which you desire to
obtain death counts.
death_other_count(
ph.data,
cause,
icdcol = "underlying_cod_code",
kingco = TRUE,
group_by = NULL,
ypll_age = NULL,
death_age_col = NULL
)
ph.data |
a data.table or data.frame. Must contain death data structured with one person per row and with at least one column of ICD10 death codes. |
cause |
a character vector specifying the complete or partial
keyword for the cause of death of interest. It is not case sensitive and you
can specify it in two ways: 1) The default is |
icdcol |
a character vector of length one that specifies the name of the column in ph.data that contains the ICD10 death codes of interest. The default is |
kingco |
a logical vector of length one. It specifies whether you want to limit the analysis to King County. NOTE
this only works with data imported with the The default is kingco = TRUE. |
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 |
ypll_age |
an optional numeric vector of length 1. When specified, it
should be the age (an integer) used for Years of Potential Life Lost (YPLL)
calculations. Valid values are between 1 & 99 (inclusive), though 65 and 85 are the most
common. For example, The default is |
death_age_col |
an optional character vector of length one that specifies
the name of the column in ph.data with the decedents' age at death
in years. It is only needed if The default is |
None
Generates a table with two columns: cause.of.death
and deaths
.
If ypll_age
is specified, a ypll_##
column will also be added to the
table. Columns in the group_by
argument will also be returned.
# example 1: death count only
set.seed(98104)
deathdata <- data.table::data.table(
cod.icd10 = c(rep("D52.1", round(runif(1, 30, 100000), 0)),
rep("E66.1", round(runif(1, 30, 100000), 0)),
rep("K85.3", round(runif(1, 30, 100000), 0)),
rep("X85", round(runif(1, 30, 100000), 0)),
rep("R78.4", round(runif(1, 30, 100000), 0)),
rep("Y13.2", round(runif(1, 30, 100000), 0)),
rep("X42.3", round(runif(1, 30, 100000), 0)),
rep("X60.7", round(runif(1, 30, 100000), 0)),
rep("J70.3", round(runif(1, 30, 100000), 0)))
)
eg1 <- death_other_count(ph.data = deathdata,
cause = "dose|induce",
icdcol = "cod.icd10",
kingco = FALSE,
ypll_age = NULL,
death_age_col = NULL)
head(eg1)
# example 2: with YPLL calculation
deathdata2 <- data.table::copy(deathdata)
set.seed(98104)
deathdata2[, ageofdeath := rads::round2(rnorm(1, mean = 70, sd = 5 ), 0),
1:nrow(deathdata2)] # synthetic age of death
eg2 <- death_other_count(ph.data = deathdata2,
cause = "dose|induce",
icdcol = "cod.icd10",
kingco = FALSE,
ypll_age = 65,
death_age_col = "ageofdeath")
head(eg2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.