Here is an example of the tables produced by {epitabulate} from a randomly generated data set based on an MSF data dictionary for Measles data.
library(epidict) library(matchmaker) library(epikit) library(dplyr) library(epitabulate) linelist <- epidict::gen_data("Measles", numcases = 1000, org = "MSF") measles_dict <- epidict::msf_dict("Measles", compact = FALSE) # Cleaning linelist data linelist_clean <- matchmaker::match_df( x = linelist, dictionary = measles_dict, from = "option_code", to = "option_name", by = "data_element_shortname", order = "option_order_in_set" ) linelist_clean
There are three functions that will provide quick statistics for different rates
based on binomial estimates of proportions from binom::binom.wilson()
attack_rate()
case_fatality_rate()
mortality_rate()
attack_rate(10, 50) case_fatality_rate(2, 50) mortality_rate(40, 50000)
In addition, it's possible to rapidly calculate Case fatality rate from a linelist, stratified by different groups (e.g. gender):
case_fatality_rate_df(linelist_clean, exit_status %in% c("Dead in facility", "Dead on arrival"), group = sex, add_total = TRUE, mergeCI = TRUE)
the_symptoms <- tab_linelist(linelist_clean, cough, nasal_discharge, severe_oral_lesions, transpose = "value" ) the_symptoms
the_symptoms %>% epikit::rename_redundant("%" = "proportion") %>% epikit::augment_redundant("(n)" = "n") %>% knitr::kable()
In R, creating 2x2 tables is as simple as using the function table()
, but
unfortunately, it can be difficult to interpret the values of these tables
because the dimensions are often flipped around for different analyses. The
function data_frame_from_2x2()
will present these values labeled unambiguously.
symptoms_tf <- linelist_clean %>% dplyr::transmute( pneumonia = grepl("Yes", pneumonia), cough = grepl("Yes", cough), nasal_discharge = grepl("Yes", nasal_discharge), oral_lesions = grepl("Yes", severe_oral_lesions), contact = grepl("known case", contact_history) ) symptoms_tf print(pxc <- with(symptoms_tf, table(pneumonia, cough))) print(pxcxc <- with(symptoms_tf, table(pneumonia, cough, contact))) data_frame_from_2x2(pxc) data_frame_from_2x2(pxcxc)
tu <- tab_univariate(symptoms_tf, outcome = pneumonia, cough, nasal_discharge, oral_lesions, contact, mergeCI = TRUE, extend_output = FALSE, measure = "OR" ) tu %>% select(-est_type) %>% epikit::augment_redundant("exposed " = "exp_") %>% rename(odds = est_ci) %>% knitr::kable(digits = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.