R/revfactorlevels.R

Defines functions revfactorlevels

Documented in revfactorlevels

# revfactorlevels.R
# ::rtemis::
# 2022 E.D. Gennatas www.lambdamd.org

#' Reverse factor level order
#'
#' @param x factor
#'
#' @export
#' @author E.D. Gennatas

revfactorlevels <- function(x) {
  if (is.factor(x)) {
    factor(x, levels = rev(levels(x)))
  } else {
    x
  }
} # rtemis::revfactorlevels
egenn/rtemis documentation built on May 4, 2024, 7:40 p.m.