na_check_prop {naflex}R Documentation

Check missing values conditions (single condition)

Description

These set of functions check a condition on missing values in a vector x. They return TRUE if check passes, and FALSE otherwise. They are special cases of na_check, which is the general case for specifying multiple checks.

Usage

na_check_prop(x, prop = NULL, strict = FALSE)

na_check_n(x, n = NULL)

na_check_consec(x, consec = NULL)

na_check_non_na(x, n_non = NULL)

Arguments

x

Vector to check the missing values properties of.

prop

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

strict

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

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.

Details

These functions replicate the functionality of na_check as individual functions for single checks.

For example, na_check_n(x, 5) is equivalent to na_check(x, n = 5).

This more restricted form may be desirable when only a single check is required.

Value

These functions return TRUE if the check passes, and FALSE otherwise.

They are convenient wrapper functions for:

Examples

na_check_prop(c(1, 2, NA, 4), 0.6)

na_check_prop(c(1, 2, NA, 4), 0.4)

na_check_prop(c(1:10, NA), 0.1)

na_check_prop(c(1:9, NA), 0.1, strict = TRUE)

na_check_n(c(1, 2, NA, 4, NA, NA, 7), 5)

na_check_n(c(1:9, NA, NA, NA), 2)

na_check_consec(c(1, NA, NA, NA, 2, NA, NA, 7), 4)

na_check_consec(c(rep(NA, 5), 1:2, rep(NA, 6)), 5)

na_check_non_na(c(1, 2, NA, 4, NA, NA, 7), 5)

na_check_non_na(c(1:9, NA, NA, NA), 2)

[Package naflex version 0.1.0 Index]