knitr::opts_chunk$set( collapse = TRUE, comment = "#>", message = TRUE, error = TRUE )
## Load libraries library(here) library(dplyr) library(ggplot2) library(Hmisc) library(naniar) ## for missing data library(gt) library(kableExtra) library(DT) load(here::here("data", "a_crash2.rda"))
Number and percentage of missing.
a_crash2 %>% select(-time2death,-ddeath, -entryid, -trandomised, -earlydeath) %>% miss_var_summary() %>% gt::gt() %>% gt::cols_label( variable = md("**Variable**"), n_miss = md("**Missing (count)**"), pct_miss = md("**Missing (%)**") ) %>% gt::fmt_number( columns = c(pct_miss), decimals = 2 )
Display
a_crash2 %>% select(-time2death,-ddeath, -entryid, -trandomised, -earlydeath) %>% gg_miss_var(show_pct = TRUE) + theme_minimal(base_size = 12) + ggtitle("Number of missing observations per variable")
Each row is a patient and each column is a measurement. Black indicates a missing observation.
a_crash2 %>% select(-time2death,-ddeath, -entryid, -trandomised, -earlydeath) %>% naniar::vis_miss(sort_miss = TRUE, show_perc_col = TRUE) + theme_minimal(base_size = 12) + ggtitle("Number of missing observations per variable")
Distribution of missing values per patients.
a_crash2 %>% select(-time2death,-ddeath, -entryid, -trandomised, -earlydeath) %>% gg_miss_case()
Relationship of missing values per patient per observation.
a_crash2 %>% select(-time2death,-ddeath, -entryid, -trandomised, -earlydeath) %>% gg_miss_upset()
This section presents patients with a least one missing value. First we list out patients with at least one missing value in a filterable table.
cc <- a_crash2 %>% select(-time2death,-ddeath) %>% filter(!complete.cases(.)) DT::datatable(cc)
Then we report the pattern of missing for this set of patients.
cc %>% gg_miss_upset()
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.