R/as_char_no_warn.r

Defines functions as_char_no_warn

Documented in as_char_no_warn

#' convert to character vector without warning
#' @param x vector, typically numeric or a factor
#' @return character vector
#' @export
as_char_no_warn <- function(x) {
  if (is.character(x)) {
    return(x)
  }
  old <- options(warn = -1)
  on.exit(options(old))
  if (is.integer(x)) {
    fastIntToStringRcpp(x)
  }
  if (is.factor(x)) {
    levels(x)[x]
  } else {
    as.character(x)
  }
}

Try the jwutil package in your browser

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

jwutil documentation built on May 7, 2019, 1:03 a.m.