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 |
Details
There are four type of checks available:
a maximum proportion of missing values allowed (
prop
)a maximum number of missing values allowed (
n
)a maximum number of consecutive missing values allowed (
consec
), anda minimum number of non-missing values required (
n_non
).
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)