Description Usage Arguments Value Errors Examples
View source: R/check_numeric_list.R
check_numeric_list
checks if all of the elements in the lst
can be a numeric value. It
returns TRUE
if all of the elements of lst
are numeric
or are numeric values in character form,
such as "1", "3.4", "-76", etc.
If with_bool
is set to TRUE
, check_numeric_list
assumes booleans
can also have an equivalent numeric form (being 1 and 0), and returns TRUE if it detects a boolean lst
.
1 | check_numeric_list(lst, with_bool = FALSE)
|
lst |
a vector or list. |
with_bool |
bool. Specifies whether we consider booleans as numeric values. |
This function returns True if the object can be converted to an equivalent numeric form.
If the lst
is of type factor
then check_numeric_list
, and any
of the numericColumns
family of functions, won't be able to detect whether the
object can be numeric or not, and it may lead to unexpected results.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run:
check_numeric_list(c(1,2,-5,6.7))
[1] TRUE
check_numeric_list(c("-2.7", 7, 9, -5, "9.8"))
[1] TRUE
check_numeric_list(list("-2.7", 7, 9, -5, "9.8"))
[1] TRUE
check_numeric_list(c("1","3", -5, "bacon"))
[1] FALSE
check_numeric_list(c(TRUE,TRUE, FALSE))
[1] FALSE
check_numeric_list(c(TRUE,TRUE, FALSE),with_bool = T)
[1] TRUE
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.