R/temp/rm_empty.R

Defines functions rm_empty

#' rm_empty
#' @param x A vector or list
#' 
#' @examples
#' # numeric
#' x <- c(1:5, NA)
#' rm_empty(x)
#' 
#' # list
#' l <- list(1:5, NULL, NA)
#' rm_empty(l)
#' 
#' @keywords internal
#' @rdname tools
#' @export
rm_empty <- function(x){
    if (is.list(x)){
        x[sapply(x, length) > 0]
    }else {
        x[!is.na(x)]
    }
}
kongdd/latticeGrob documentation built on March 30, 2024, 3:35 a.m.