R/binarize_with_sign.R

Defines functions binarize_with_sign

#' binarize_with_sign
#'
#' binarizes the data based on the threshold using the absolute value of the data.
#' Gives a sign based on the sign of the input data.
#' @param data numerical vector
#' @param threshold threshold used to binarise the data
#' @noRd
binarize_with_sign <- function(data,threshold){
    
    out = sign(data) * as.numeric(abs(data) >= threshold)
    return(out)
}
saezlab/COSMOS documentation built on Sept. 17, 2023, 1:22 p.m.