I have a dataframe:
structure(list(diag = structure(list(svm.ca = 0.894598155467721, rpart.ca = 1), .Names = c("svm.ca", "rpart.ca")), kappa = structure(list( svm.ca = 0.838953088986906, rpart.ca = 1), .Names = c("svm.ca", "rpart.ca")), rand = structure(list(svm.ca = 0.871202561348254, rpart.ca = 1), .Names = c("svm.ca", "rpart.ca")), crand = structure(list( svm.ca = 0.715005579974998, rpart.ca = 1), .Names = c("svm.ca", "rpart.ca"))), .Names = c("diag", "kappa", "rand", "crand"), row.names = c("svm", "rpart"), class = "data.frame")
It looks like this:
diag kappa rand crand
svm.ca 0.8945982 0.8389531 0.8712026 0.7150056
rpart.ca 1 1 1 1
I'm trying to follow the svm directions here (page 3), and I want to show a grouped histogram of these values. So, I melt my df:
df <- melt(as.matrix(histdf))
Which gives me this monstrosity here:
X1 X2 value.diag value.kappa value.rand value.crand
1 svm diag 0.8945982 0.8389531 0.8712026 0.7150056
2 rpart diag 1 1 1 1
3 svm kappa 0.8945982 0.8389531 0.8712026 0.7150056
4 rpart kappa 1 1 1 1
5 svm rand 0.8945982 0.8389531 0.8712026 0.7150056
6 rpart rand 1 1 1 1
7 svm crand 0.8945982 0.8389531 0.8712026 0.7150056
8 rpart crand 1 1 1 1
I've also tried:
> df <- melt(histdf)
Using as id variables
> df
variable value NA
1 diag 0.8945982 1
2 diag 0.8945982 1
3 kappa 0.8389531 1
4 kappa 0.8389531 1
5 rand 0.8712026 1
6 rand 0.8712026 1
7 crand 0.7150056 1
8 crand 0.7150056 1
And from this:
rownames(histdf)<-c("svm","rpart")
histdf$rn <- row.names(histdf)
df <- melt(histdf, id.vars = "rn")
Which gives me the same output as the previous attempt. I mean I should be getting a Name, value table, right? Not variable, value, NA - howma gonna plot that?
I know this isn't going to work for a grouped ggplot histogram like this (I have attempted a lot): https://stackoverflow.com/a/18162330/1152809