Validate if the provided object is empty
Value
isEmpty()
returnsTRUE
if the object is empty;FALSE
otherwise.validateIsNotEmpty()
returnsNULL
if validation is successful. Otherwise, error is signaled.
Examples
# empty list or data.frame
isEmpty(NULL)
#> [1] TRUE
isEmpty(numeric())
#> [1] TRUE
isEmpty(list())
#> [1] TRUE
isEmpty(data.frame())
#> [1] TRUE
# accounts for filtering of arrays and data.frame
df <- data.frame(x = c(1, 2, 3), y = c(4, 5, 6))
isEmpty(df)
#> [1] FALSE
isEmpty(df$x[FALSE])
#> [1] TRUE
isEmpty(df[FALSE, ])
#> [1] TRUE
# validation helper
validateIsNotEmpty(list(1, 2)) # NULL
#> NULL
# validateIsNotEmpty(NULL) # error