is.empty: Checks if an object is empty (e.g: of zero length)

Description Usage Arguments Details Value Author(s) Source See Also Examples

Description

Checks if an object is empty (e.g: of zero length) and returns TRUE/FALSE

Usage

1

Arguments

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.

Details

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.

Value

Returns TRUE/FALSE if the object is empty or not.

Author(s)

James (http://stackoverflow.com/users/269476/james)

Source

http://stackoverflow.com/questions/6451152/how-to-catch-integer0

See Also

integer, identical

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
is.empty(integer(0)) #TRUE
is.empty(0L)         #FALSE
is.empty(numeric(0)) #TRUE
is.empty(NA) # FALSE 
is.empty(FALSE) # FALSE 
is.empty(NULL) # FALSE (with a warning)

a <- which(1:3 == 5)
b <- numeric(0)
is.empty(a)
is.empty(a,"numeric")
is.empty(b)
is.empty(b,"integer")


Search within the installr package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.