I want to collapse my dataframe so that there's only one factor variable per row and the values all collapse on themselves to one row each. Here's an example:
mat <- data.frame(type = c(rep("int",5), rep("num",5)), diag(sample.int(9,6), 10))
mat[mat == 0] <- NA
mat[5,11] <- 4
Now I want this to be:
See Question&Answers more detail:ostype, X1, ..., X8, X9, X10
int, 2, 7, ...,NA, NA, 4
num, NA, NA, ..., 3, 1