onehot2factor: Convert one-hot encoded matrix to factor

View source: R/onehot2factor.R

onehot2factorR Documentation

Convert one-hot encoded matrix to factor

Description

Convert one-hot encoded matrix to factor

Usage

onehot2factor(x, labels = colnames(x))

Arguments

x

one-hot encoded matrix or data.frame

labels

Character vector of level names. Default = colnames(x)

Details

If input has a single column, it will be converted to factor and returned

Author(s)

E.D. Gennatas

Examples

## 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
onehot2factor(x)

## End(Not run)


egenn/rtemis documentation built on Nov. 22, 2024, 4:12 a.m.