get_valid {clinpubr} | R Documentation |
Get one valid value from vector.
Description
Extract one valid (non-NA) value from a vector.
Usage
get_valid(x, mode = c("first", "mid", "last"), disjoint = FALSE)
Arguments
x |
A vector. |
mode |
The mode of the valid value to extract. |
disjoint |
If TRUE, the values extracted by the three modes are forced to be different. This behavior might be desired when trying to extract different values with different modes. The three modes extract values in the sequence: "first", "last", "mid". |
Value
A single valid value from the vector. NA
if all values are invalid.
Examples
get_valid(c(NA, 1, 2, NA, 3, NA, 4))
get_valid(c(NA, 1, NA), mode = "last", disjoint = TRUE)
[Package clinpubr version 1.0.1 Index]