I have an issue with my grouped barplot.
I have the following data:
accuracy sensitivity specificity auc rating
1 77.22019 89.22559 76.02808 82.62684 1
2 72.20195 89.14729 71.50997 80.32863 2
3 68.36983 95.48387 67.02841 81.25614 3
4 61.40511 73.25000 59.76454 66.50727 4
5 68.36983 95.48387 67.02841 81.25614 5
I use this code to create a grouped barplot:
library(ggplot2)
library(tidyr)
eval.df %>%
gather("Measures", "Percent",-rating) %>%
ggplot(aes(rating, Percent, fill = Measures)) +
geom_bar(position = "dodge", stat = "identity")
I get this barplot:
But I want to change the order of the bars as well as the legend so that after "accuracy" comes "sensitivity", then "specificity" and then "auc".
I know that this is done when the different bars would represent different values of one variable (e.g., just defining the levels). But as in my case they are variables, I can't find a solution.
(Additionally, I would like to change the Names of the legend manually, if someone knows how to do this as well)
Thank you very much in advance!