one_hot2factor | R Documentation |
Convert one-hot encoded matrix to factor
one_hot2factor(x, labels = colnames(x))
x |
one-hot encoded matrix or data.frame. |
labels |
Character vector of level names. |
If input has a single column, it will be converted to factor and returned
A factor.
EDG
## Not run:
x <- data.frame(matrix(F, 10, 3))
colnames(x) <- c("Dx1", "Dx2", "Dx3")
x$Dx1[1:3] <- x$Dx2[4:6] <- x$Dx3[7:10] <- T
one_hot2factor(x)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.