R/factor2character.R

Defines functions factor2character

Documented in factor2character

#' Factor to Character
#'
#' Turns a factor into a plain character vector.
#'
#' @param x Factor to be transformed
#'
#' @return Character vector, i.e. the factor without the levels.
#'
#' @export
factor2character <- function(x) {
  if (is.factor(x)) {
    return(levels(x)[as.numeric(x)])
  } else {
    return(x)
  }
}
hkauhanen/hipster documentation built on July 4, 2020, 11:25 p.m.