binarize: Binarize an input value based on a 'threshold'

Description Usage Arguments Details Value Examples

View source: R/accessory_funcs.R

Description

Binarize an input value based on a threshold

Usage

1
binarize(x, threshold = NULL, rep_na = NA, verbose = FALSE)

Arguments

x

numeric; A vector to binarize

threshold

numeric; The threshold for binarizing. Will default to the center number between max and min.

rep_na

numeric; The value to replace missing values with. Default NA.

verbose

boolean; flag for whether to display threshold or not

Details

Assigns a value of 0 or 1 based on being < or > the thresdhold, respectively. If x = threshold, x = 0. NA values are assigned as rep_na

Value

vector; contains 0,1, if below or above the threshold, or 'rep.na' if NA

Examples

1
2
vals <- c(0,0.25,0.5,0.75,1,NA)
binarize(vals, threshold=0.5)

CompEpigen/scMethrix documentation built on Nov. 6, 2021, 3:09 p.m.