R/customRound.R

Defines functions customRound

Documented in customRound

#' Custom Rounding
#'
#' Does custom rounding on user defined cutpoint for classification problems.
#'
#' @param num The number being rounded.
#' @param pos_thresh The threshold between 0 and 1 that the number will be rounded.
#' @return A rounded number at the defined threshold.
#' @export


customRound <- function(num, pos_thresh) {
  adj <- pos_thresh - 0.5
  num_adj <- num - adj
  num_adj <- ifelse(num_adj < 0, 0, num_adj)
  return(round(num_adj))
}
blazickjoe/DataScienceLibrary documentation built on Nov. 5, 2019, 2:26 p.m.