R/is_empty.R

Defines functions is_empty is.empty is_empty.default is_empty.data.frame

Documented in is_empty is.empty is_empty.data.frame is_empty.default

#' @title 
#' Test emptyness
#' 
#' @description 
#' These methods test if an object \code{x} is empty. 
#' 
#' @param x
#' An object to be tested. 
#' 
#' @return 
#' \code{TRUE} if \code{x} is empty, \code{FALSE} otherwise. 
#' 
#' @seealso 
#' \code{\link[bazar]{as_empty}} in this package. 
#' 
#' @export
#' 
#' @examples 
#' is_empty(4)
#' is_empty(c())
#' is_empty(new.env())
#' is_empty(character(0))
#' is_empty(list())
#' is_empty(integer(0))
#' is_empty(data.frame())
#' 
is_empty <- 
function(x)
{
  UseMethod("is_empty")
}


#' @export
#' @rdname is_empty
#' 
is.empty <- 
function(x)
{
  .Deprecated("is_empty")
  is_empty(x)
}


#' @export
#' @rdname is_empty
#' 
is_empty.default <- 
function(x)
{
  length(x)==0L
}


#' @export
#' @rdname is_empty
#' 
is_empty.data.frame <- 
function(x)
{
  nrow(x) == 0L #|| ncol(x) == 0L
}
paulponcet/bazar documentation built on July 15, 2019, 5:28 a.m.