R/log_2.R

Defines functions log_2

Documented in log_2

#' Title
#'
#' @param x numeric number
#'
#' @return log transformation of x 
#' @export
#'
#' @examples
#' x <- 4
#' log_2(x)
#' 
#' x <- -1 # show error message 
#' try(log_2(x))
log_2 = function(x){
  if(x > 0){
    log(x)
  }else{
    rlang::abort(message = "negative input, NA introduced!",
                 .subclass ="get_val_error",
                 invalid_input = x)
  }
}
Hung-Ching-Chang/biost2094_hw2 documentation built on March 19, 2022, 2:29 a.m.