categorize {cases} | R Documentation |
Categorize continuous values
Description
This function allows to split continuous values, e.g. (risk) scores or (bio)markers, into two or more categories by specifying one or more cutoff values.
Usage
categorize(
values,
cutoffs = rep(0, ncol(values)),
map = 1:ncol(values),
labels = NULL
)
Arguments
values |
(matrix) |
cutoffs |
(numeric | matrix) |
map |
(numeric) |
labels |
(character) |
Value
(matrix)
numeric (n x k) matrix with categorical outcomes after categorizing.
Examples
set.seed(123)
M <- as.data.frame(mvtnorm::rmvnorm(20, mean = rep(0, 3), sigma = 2 * diag(3)))
M
categorize(M)
C <- matrix(rep(c(-1, 0, 1, -2, 0, 2), 3), ncol = 3, byrow = TRUE)
C
w <- c(1, 1, 2, 2, 3, 3)
categorize(M, C, w)