mortality_rate {ems}R Documentation

Mortality Rate

Description

mortality_rate function returns a list with the mortality rate and the number of patients for each month or quarter of the year.

Usage

mortality_rate(
  deaths,
  period = NULL,
  isQuarter = FALSE,
  isYear = FALSE,
  option = c("both", "monthly", "quarterly", "annual"),
  periodName = NULL,
  default_tapply = NA
)

Arguments

deaths

a numerical vector that only contains 0 and 1, indicating whether the patient was alive or dead, respectively.

period

a numerical vector that contains the order of months when the patients were admitted to the hospital unit. If period variable is NULL (the default), the function will return a single mortality rate.

isQuarter

logical indicating whether the period refers to quarter or not. The default is FALSE.

isYear

logical indicating whether the period refers to years or not. The default is FALSE.

option

a character string which determines what the function mortality_rate returns. If the option is chosen to be 'both' (the default), the function will return a list containing monthly mortality rate, quarterly mortality rate, annual mortality rate and the number of patients in each month, quarter and year. If the option is 'monthly', only the monthly mortality rate and the number of patients in each month are returned. If the option is 'quarterly', only the quarterly mortality rate and the number of patients in each quarter are returned. If the option is 'annual', only the annual mortality rate and the number of patients in each year are returned.

periodName

a character vector that contains the name of months when the patients were admitted to de hospital unit. Used only if period is not NULL.

default_tapply

argument to set the default in tapply function when evaluating the mortality rate for each period. Can be equal to 0 or NA (the default).

Author(s)

Camila Cardoso <camila.cardoso@epimedsolutions.com> Lunna Borges <lunna.borges@epimedsolutions.com>

Examples


# Loading the dataset
data(icu)

# Creating a vector of months
date <- as.Date(icu$UnitDischargeDateTime, tryFormats = '%d/%m/%Y')
months <- as.numeric(format(date, '%m'))

# Vector of deaths
deaths <- icu$UnitDischargeName

# Calculating monthly and quarterly mortality rate
mortality_rate(deaths = deaths, period = months, option = 'both')



[Package ems version 1.3.11 Index]