check_nonnum {clinpubr} | R Documentation |
Check elements that are not numeric
Description
Finds the elements that cannot be converted to numeric in a character vector. Useful when setting the strategy to clean numeric values.
Usage
check_nonnum(
x,
return_idx = FALSE,
show_unique = TRUE,
max_count = NULL,
random_sample = FALSE,
fix_len = FALSE
)
Arguments
x |
A string vector that stores numerical values. |
return_idx |
A logical value.
If |
show_unique |
A logical value. If |
max_count |
An integer. The maximum number of elements to show.
If |
random_sample |
A logical value. If |
fix_len |
A logical value. If |
Details
The function uses the as.numeric()
function to try to convert the elements to numeric.
If the conversion fails, the element is considered non-numeric.
Value
The (unique) elements that cannot be converted to numeric,
and their indexes if return_idx
is TRUE
.
Examples
check_nonnum(c("\uFF11\uFF12\uFF13", "11..23", "3.14", "2.131", "35.2."))