categorize | R Documentation |
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.
categorize(
values,
cutoffs = rep(0, ncol(values)),
map = 1:ncol(values),
labels = NULL
)
values |
(matrix) |
cutoffs |
(numeric | matrix) |
map |
(numeric) |
labels |
(character) |
(matrix)
numeric (n x k) matrix with categorical outcomes after categorizing.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.