Skip to content
Prev 308430 / 398503 Next

Matrix to data.frame with factors

Hello,

Try the following.

x <- matrix(sample(0:1, 12, TRUE), ncol = 4)
y <- data.frame(apply(x, 2, factor))
str(y)

Hope this helps,

Rui Barradas
Em 19-10-2012 12:04, brunosm escreveu: