check_numeric_list: check_numeric_list

Description Usage Arguments Value Errors Examples

View source: R/check_numeric_list.R

Description

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.

Usage

1
check_numeric_list(lst, with_bool = FALSE)

Arguments

lst

a vector or list.

with_bool

bool. Specifies whether we consider booleans as numeric values.

Value

This function returns True if the object can be converted to an equivalent numeric form.

Errors

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.

Examples

 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)

ronybsulca/numericColumns documentation built on May 29, 2019, 1:19 p.m.