Does the input have a non-zero or defined length?
Source:R/check-scalar-hasLength.R
check-scalar-hasLength.Rd
Does the input have a non-zero or defined length?
Arguments
- x
Object.
- n
NULL
orinteger
. IfNULL
(default), the function will check to see if the input length is non-zero.
Examples
## TRUE ====
hasLength(1L)
#> [1] TRUE
hasLength(FALSE)
#> [1] TRUE
hasLength(datasets::mtcars)
#> [1] TRUE
hasLength("")
#> [1] TRUE
## FALSE ====
hasLength(NULL)
#> [1] FALSE
hasLength(character())
#> [1] FALSE
hasLength(data.frame())
#> [1] FALSE