Checks if an object is empty (e.g: of zero length) and returns TRUE/FALSE
is.empty(x, mode = NULL, ...)
x | an object |
---|---|
mode | is the object an empty (zero length) object of this mode (can be "integer", "numeric", and so on...) |
... | none are available. |
https://stackoverflow.com/questions/6451152/how-to-catch-integer0
Returns TRUE/FALSE if the object is empty or not.
Uses identical and avoids any attribute problems by using the fact that it is the empty set of that class of object and combine it with an element of that class.
James (https://stackoverflow.com/users/269476/james)
#> [1] TRUEis.empty(0L) #FALSE#> [1] FALSE#> [1] TRUEis.empty(NA) # FALSE#> [1] FALSEis.empty(FALSE) # FALSE#> [1] FALSEis.empty(NULL) # FALSE (with a warning)#> Warning: x is NULL#> [1] FALSE#> [1] TRUEis.empty(a,"numeric")#> [1] FALSEis.empty(b)#> [1] TRUEis.empty(b,"integer")#> [1] FALSE