col(., as.factor = TRUE) , ( ).
df[] <- paste(col(df, TRUE), as.matrix(df), sep = ":")
:
1 2 3 4 5
1 1:1 2:0.5 3:0.5 4:0 5:1
2 1:0.5 2:0.5 3:0.5 4:0 5:1
3 1:1 2:1 3:0 4:0 5:1
4 1:1 2:1 3:0 4:0 5:1
5 1:1 2:1 3:0 4:0 5:1
, as.factor = TRUE . , .
df[] <- paste(col(df), as.matrix(df), sep = ":")
P.S. 100% .
:
df <- structure(list(`1` = c(1, 0.5, 1, 1, 1), `2` = c(0.5, 0.5, 1,
1, 1), `3` = c(0.5, 0.5, 0, 0, 0), `4` = c(0L, 0L, 0L, 0L, 0L
), `5` = c(1L, 1L, 1L, 1L, 1L)), .Names = c("1", "2", "3", "4",
"5"), class = "data.frame", row.names = c("1", "2", "3", "4",
"5"))