R/as_numeric.r

Defines functions as_numeric.factor as_numeric

Documented in as_numeric

#' Convert to numeric.
#'
#' @param x Object to coerce to type factor.
#' @param ... Additional arguments.
#'
#' @export
as_numeric <- function(x, ...) UseMethod("as_numeric")

#' @rdname as_numeric factor
#' @method as_numeric factor
#' @export
as_numeric.factor <- function(x, ..., by.level=TRUE)
{
  if (by.level)
    factor_to_numeric_bylevel(x, levels(x))
  else
    as.numeric(x)
}
wrathematics/fastercaster documentation built on May 28, 2017, 5:18 a.m.