na_check {naflex}R Documentation

Check missing values conditions

Description

na_check checks conditions on missing values in a vector. If all the checks pass it returns TRUE, otherwise FALSE.

Usage

na_check(
  x,
  prop = NULL,
  n = NULL,
  consec = NULL,
  n_non = NULL,
  prop_strict = FALSE
)

Arguments

x

Vector to check the missing values properties of.

prop

The maximum proportion (0 to 1) of missing values allowed.

n

The maximum number of missing values allowed.

consec

The maximum number of consecutive missing values allowed.

n_non

The minimum number of non-missing values required.

prop_strict

A logical (default FALSE) indicating if the proportion of missing values must be strictly less than prop (prop_strict = TRUE) or only less than prop (prop_strict = FALSE).

Details

There are four type of checks available:

Any number of checks may be specified, including none. If multiple checks are specified, they must all pass in order to return TRUE. If no checks are specified then TRUE is returned, since this is considered as "all" checks passing.

Value

TRUE if all specified checks pass, and FALSE otherwise.

Examples

x <- c(1:3, NA, NA, NA, 4, NA, NA, 3)
# check if no more than 50% of values are missing
na_check(x, prop = 0.5)
# check if no more than 50% of values are missing
# and if there are no more than 2 consecutive missing values.
na_check(x, prop = 0.5, consec = 2)

[Package naflex version 0.1.0 Index]