R/Rdich.R

Defines functions Rdich

#' ## **`Rdich()`**
#'
#' Function for dichotomizing numeric data.^[This probably exists in one or more packages, but the function simple enough to define here, so I'd rather just do myself.]
#'
Rdich <- function(x,
                   min = 0,
                   values = c(0, 1)) {
    if (is.numeric(x)) {
        x <- ifelse(x <= min, values[1], values[2])
    }
    else
        stop('x must be numeric')
    return(x)
}
#'
EccRiley/Riley documentation built on Feb. 15, 2024, 9:29 a.m.