missing_tbl: Generate a table of "missingness"

View source: R/missing_tbl.R

missing_tblR Documentation

Generate a table of "missingness"

Description

Create a table of missing values along with percentages. It may be undesirable to count a variable if it is dependent on another one. This can be accounted for here by using a named vector where the name is the dependent variable and the value is the indpendent variable. c("B" = "A") can be thought of here as "B depends on A". In other words, each entry in B will only be evaluated if A is not missing. If the input is a labeled data frame, the final output will include a column of labels.

Usage

missing_tbl(data, depends = NA)

Arguments

data

A tbl.

depends

A named vector representing variable dependencies. For example, c("B" = "A", "C" = "B") can be read as "B depends on A and C depends on B". If a value for B is missing, it will only be counted if A is not missing, and similarly for C and B.

Examples

data <- tibble::tribble(
  ~A, ~B, ~C,
  1, 2, 3,
  NA, NA, 6,
  7, NA, 9
)

data

missing_tbl(data)

missing_tbl(data, depends = c("B" = "A"))


overdodactyl/mRclwhip documentation built on June 30, 2023, 6:24 a.m.