R/sqrt_3.R

Defines functions sqrt_3

Documented in sqrt_3

#' Title
#'
#' @param x numeric number
#'
#' @return the square root of x
#' @export
#'
#' @examples
#' set.seed(2)
#' (y = lapply(runif(2,-10,10), sqrt_3))
#' y[[1]]$invalid_input
sqrt_3 = function(x){
  if(x > 0){
    sqrt(x)
  }else{
    rlang::catch_cnd(rlang::abort(message = "negative input and NA introduced!",
                                  .subclass ="invalid_input",
                                  invalid_input = x))
  }
}
Hung-Ching-Chang/biost2094_hw2 documentation built on March 19, 2022, 2:29 a.m.