Check if values are NULL, NA, blank after trimming, or an empty list

is_nowt(x, test_for = c("null", "na", "trim", "empty"))

Arguments

x

vector or list to test

test_for

values to test for ("null" replaces NULL values, "na", replaces NA values, "trim" replaces empty strings after trimws(), "empty" replaces empty lists)

Value

vector or list of logical values

Examples

x <- list(NULL, NA, " ", list())
is_nowt(x)
#> [[1]]
#> [1] TRUE
#> 
#> [[2]]
#> [1] TRUE
#> 
#> [[3]]
#> [1] TRUE
#> 
#> [[4]]
#> [1] TRUE
#> 
is_nowt(x, test_for = "null")
#> [[1]]
#> [1] TRUE
#> 
#> [[2]]
#> [1] FALSE
#> 
#> [[3]]
#> [1] FALSE
#> 
#> [[4]]
#> [1] FALSE
#> 
is_nowt(x, test_for = "na")
#> [[1]]
#> [1] FALSE
#> 
#> [[2]]
#> [1] TRUE
#> 
#> [[3]]
#> [1] FALSE
#> 
#> [[4]]
#> [1] FALSE
#> 
is_nowt(x, test_for = "trim")
#> [[1]]
#> [1] FALSE
#> 
#> [[2]]
#> [1] FALSE
#> 
#> [[3]]
#> [1] TRUE
#> 
#> [[4]]
#> [1] FALSE
#> 
is_nowt(x, test_for = "empty")
#> [[1]]
#> [1] FALSE
#> 
#> [[2]]
#> [1] FALSE
#> 
#> [[3]]
#> [1] FALSE
#> 
#> [[4]]
#> [1] TRUE
#>