R/droplevels.R

#' @method droplevels lfactor
#' @export
droplevels.lfactor <- function(x, ...) {
	labels <- attributes(x)$levels
	levels <- attributes(x)$llevels
	cookie_cutter <- labels %in% x
	labels <- labels[cookie_cutter]
	levels <- levels[cookie_cutter]
	return(lfactor(switchllevels(x), levels=levels, labels=labels, exclude=NULL))
	#attr(x, "levels") <- labels
	#attr(x, "llevels") <- levels
	#return(x)
}

Try the lfactors package in your browser

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

lfactors documentation built on May 2, 2019, 8:29 a.m.