R/getUsedFactorLevels.R

Defines functions getUsedFactorLevels

Documented in getUsedFactorLevels

#' Determines used factor levels.
#'
#' Determines the factor levels of a factor type vector
#' that are actually occuring in it.
#'
#' @param x [\code{factor}]\cr
#'   The factor.
#' @return [\code{character}]
#' @export
getUsedFactorLevels = function(x) {
  intersect(levels(x), unique(x))
}

Try the BBmisc package in your browser

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

BBmisc documentation built on Sept. 29, 2022, 5:12 p.m.