R/flag_suicide_deaths.R

Defines functions flag_suicide_deaths

Documented in flag_suicide_deaths

#' Flag suicide deaths (no accidental poisoning)
#'
#' TODO: Make this also work with ICD-9
#'
#' @param df processed MCOD dataframe
#'
#' @return new dataframe
#' @importFrom dplyr mutate
#' @export
flag_suicide_deaths <- function(df) {
    new_df <- df %>%
        mutate(suicide_death = grepl("U03|X[67]\\d{1}|X8[01234]|Y870",
                                   ucod) + 0)

    return(new_df)
}
mkiang/narcan documentation built on Sept. 26, 2024, 7:18 a.m.