Does an object contain anything?

is_empty(x, recursive = TRUE)

Arguments

x

An R object, typically a list or vector.

recursive

logical, whether to unlist x to check for contents at any depth.

Value

logical, whether x contains anything.

See also

Examples

library(salinasr) vec <- NULL vec
#> NULL
is_empty(vec)
#> [1] TRUE
nested_list <- list(a = list(b = list(c = list(d = NULL), e = NULL), f = NULL), g = NULL) nested_list
#> $a #> $a$b #> $a$b$c #> $a$b$c$d #> NULL #> #> #> $a$b$e #> NULL #> #> #> $a$f #> NULL #> #> #> $g #> NULL #>
is_empty(nested_list)
#> [1] TRUE
is_empty(nested_list, recursive = FALSE)
#> [1] FALSE