Is a character variable defined
is_empty(x, empty = "\\s*")
x | Character value to evaluate |
---|---|
empty | Indicate what 'empty' means. Default is empty string (i.e., "") |
TRUE if empty, else FALSE
Is a variable NULL or an empty string
is_empty("")#> [1] TRUEis_empty(NULL)#> [1] TRUEis_empty(NA)#> [1] TRUEis_empty(c())#> [1] TRUEis_empty("none", empty = "none")#> [1] TRUEis_empty("")#> [1] TRUEis_empty(" ")#> [1] TRUEis_empty(" something ")#> [1] FALSE#> [1] FALSE#> [1] FALSEis_empty(mtcars)#> [1] FALSE