R/as_char_no_warn.R

Defines functions as_char_no_warn

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

Try the icd package in your browser

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

icd documentation built on July 2, 2020, 4:07 a.m.