Last updated: 2021-06-11

Checks: 7 0

Knit directory: ampel-leipzig-meld/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20210604) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version ba5de74. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    _targets/
    Ignored:    container/

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/missing.Rmd) and HTML (docs/missing.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
html 6541fae Sebastian Gibb 2021-06-11 fix: add targets for missing/corrplot
Rmd 76196cb Sebastian Gibb 2021-06-11 fix: wrong plot call
Rmd ecd9fde Sebastian Gibb 2021-06-11 feat: plot missing values
Rmd 851d2e1 Sebastian Gibb 2021-06-11 feat: add missing data overview

library("targets")
tar_load(raw_data)

.dotplot <- function(x, xlim = c(0, length(x)),
                     col = palette.colors(2L)[2L], pch = 19L) {
    old.par <- par(no.readonly = TRUE)
    on.exit(par(old.par))

    n <- length(x)

    mai <- par("mai")
    w <- max(strwidth(names(x), "inch"), na.rm = TRUE) + 1/16
    if (mai[2L] < w)
        mai[2L] <- mai[4L] + w # taken from dotchart
    par(mai = mai)

    plot(NA, xlim = xlim, ylim = c(0L, n + 1L), axes = FALSE)
    title(main = "Missing Data", adj = 0L)
    title(xlab = "Frequency", adj = 1L)
    y <- seq_len(n)
    mtext(
        names(x), at = y, adj = 0L, side = 2L, las = 2L,
        line = (w + 0.1) / par("csi"), cex = 0.8
    )
    abline(h = y, col = "#808080", lty = "dotted", lwd = 1L)
    points(x, y, col = col, pch = pch)
    axis(1L, lwd.ticks = 0L, col = "#808080")
}

.image <- function(x, col = c("white", palette.colors(2L)[2L])) {
    old.par <- par(no.readonly = TRUE)
    on.exit(par(old.par))

    nr <- nrow(x)
    nc <- ncol(x)
    nms <- colnames(x)

    mai <- par("mai")
    w <- max(strwidth(nms, "inch"), na.rm = TRUE) + 1/16
    if (mai[2L] < w)
        mai[2L] <- mai[4L] + w # taken from dotchart
    par(mai = mai)

    y <- seq_len(nc)
    image(
        1L:nr, y, x[, rev(y)], col = col,
        xlim = 0.5 + c(0L, nr), ylim = 0.5 + c(0L, nc),
        axes = FALSE, xlab = "", ylab = ""
    )
    title(main = "Missing Data", adj = 0L)
    title(xlab = "Rows", adj = 1L)
    mtext(
        rev(nms), at = y, adj = 0L, side = 2L, las = 2L,
        line = (w + 0.1) / par("csi"), cex = 0.75
    )
    abline(h = y, col = "#808080", lty = "dotted", lwd = 1L)
}

Missing Data

m <- raw_data
m$Sex <- as.numeric(m$Sex)
m <- as.matrix(m)
mna <- is.na(m)
mode(mna) <- "numeric"
tbl <- colSums(mna)
na <- sort(tbl[tbl > 0L], decreasing = TRUE)
knitr::kable(
    cbind(na, round(colMeans(mna[, names(na)]) * 100, 2)),
    col.names = c("# Missing Data", "% of Missing Data")
)
# Missing Data % of Missing Data
BILID_S 82 12.54
B_MPV_E 64 9.79
IL6_S 56 8.56
VDT_OH_S 47 7.19
B_PLT_E 26 3.98
B_WBC_E 23 3.52
CRP_S 14 2.14
ALAT_S 10 1.53
NA_S 9 1.38
ASAT_S 8 1.22
PTH_S 8 1.22
AP_S 7 1.07
CYSC_S 7 1.07
ALB_S 6 0.92
CHE_S 6 0.92
GGT_S 6 0.92
PROT_S 6 0.92
PALB_S 5 0.76
Dialysis 2 0.31
INR_C 2 0.31
Cirrhosis 1 0.15
SBP 1 0.15
CA_S 1 0.15
CL_S 1 0.15
P_S 1 0.15
.dotplot(sort(na), xlim = c(0L, nrow(m)))

Version Author Date
6541fae Sebastian Gibb 2021-06-11
.image(mna)

Version Author Date
6541fae Sebastian Gibb 2021-06-11

sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-unknown-linux-gnu (64-bit)

Matrix products: default
BLAS/LAPACK: /gnu/store/bs9pl1f805ins80xaf4s3n35a0x2lyq3-openblas-0.3.9/lib/libopenblasp-r0.3.9.so

locale:
 [1] LC_CTYPE=de_DE.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=de_DE.UTF-8        LC_COLLATE=de_DE.UTF-8    
 [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=de_DE.UTF-8   
 [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] targets_0.4.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6        highr_0.9         pillar_1.6.1      compiler_4.1.0   
 [5] later_1.2.0       git2r_0.28.0      workflowr_1.6.2   tools_4.1.0      
 [9] digest_0.6.27     evaluate_0.14     lifecycle_1.0.0   tibble_3.1.2     
[13] pkgconfig_2.0.3   rlang_0.4.11      igraph_1.2.6      cli_2.5.0        
[17] yaml_2.2.1        xfun_0.23         withr_2.4.2       stringr_1.4.0    
[21] knitr_1.33        fs_1.5.0          vctrs_0.3.8       tidyselect_1.1.1 
[25] rprojroot_2.0.2   glue_1.4.2        data.table_1.14.0 R6_2.5.0         
[29] processx_3.5.2    fansi_0.5.0       rmarkdown_2.8     purrr_0.3.4      
[33] callr_3.7.0       magrittr_2.0.1    whisker_0.4       promises_1.2.0.1 
[37] ps_1.6.0          codetools_0.2-18  ellipsis_0.3.2    htmltools_0.5.1.1
[41] httpuv_1.6.1      utf8_1.2.1        stringi_1.6.2     crayon_1.4.1