R/subset.R

#' @method [ lfactor
#' @export
"[.lfactor" <- function(x,i, ..., drop=FALSE) {
  xo <- x
  class(xo) <- "factor"
  if(!missing(i)) {
    res <- xo[i,...,drop=FALSE]
  } else {
    res <- xo[...,drop=FALSE]
  }
  attr(res,"llevels") <- llevels(x)
  class(res) <- c("lfactor", "factor")
  if(drop) {
    res <- droplevels(res)
  }
  res
}

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.