is_valid_ish | R Documentation |
Check if data is close to “valid"
is_valid_ish(
x,
min_len = 1,
max_len = Inf,
mode = NA,
na = TRUE,
blank = FALSE,
all = FALSE
)
x |
data to check |
min_len, max_len |
minimal and maximum length |
mode |
which storage mode (see |
na |
whether |
blank |
whether blank string considered invalid? |
all |
if |
logicals whether input x
is valid
# length checks
is_valid_ish(NULL) # FALSE
is_valid_ish(integer(0)) # FALSE
is_valid_ish(integer(0), min_len = 0) # TRUE
is_valid_ish(1:10, max_len = 9) # FALSE
# mode check
is_valid_ish(1:10) # TRUE
is_valid_ish(1:10, mode = 'numeric') # TRUE
is_valid_ish(1:10, mode = 'character') # FALSE
# NA or blank checks
is_valid_ish(NA) # FALSE
is_valid_ish(c(1,2,NA), all = FALSE) # FALSE
is_valid_ish(c(1,2,NA), all = TRUE) # TRUE as not all elements are NA
is_valid_ish(c('1',''), all = FALSE) # TRUE
is_valid_ish(1:3, all = FALSE) # TRUE as 1:3 are not characters
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.