R/lenu.R

Defines functions lenu

Documented in lenu

#' lenu: Length of unique values
#'
#' Extract unique elements and get the length of those elements
#'
#' @param x a vector or a data frame or an array or NULL.
#' @return a vector, data frame, or array-like 'x' but with duplicate
#' elements/rows removed.
#' @examples
#' unique(c(10, 3, 7, 10))
#' lenu(c(10, 3, 7, 10))
#' unique(c(10, 3, 7, 10, NA))
#' lenu(c(10, 3, 7, 10, NA))
#' lenu(c("b", "z", "b", "a", NA, NA, NA))
#' @export
lenu <- function(x = NULL) {
  return(length(unique(x)))
}

Try the kim package in your browser

Any scripts or data that you put into this service are public.

kim documentation built on Oct. 9, 2023, 5:08 p.m.