R/sqrt_2.R

Defines functions sqrt_2

Documented in sqrt_2

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