Binarize an input value based on a threshold
binarize(x, threshold = NULL, rep_na = NA, verbose = FALSE)
| 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 |
vector; contains 0,1, if below or above the threshold, or 'rep.na' if NA
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
#> [1] 0 0 0 1 1 NA