Hello Everyone, below is my dataframe.
data.frame( stringsAsFactors = FALSE, Status1 = c("No Phonecall", "Phonecall"), yes = c(110, 24), no = c(444, 176), uncertain = c(68, 11)) tata1 <- data.frame(Status1, no, yes, uncertain)
ggplot2, dplyr and tidyr packages are then loaded from library. I get a plot when I enter the code below. Image attached.
tata1 %>% gather(key = "Rescan", value = value, -Status1) %>% group_by(Status1) %>% mutate(value = value/sum(value)*100) %>% ggplot(aes(y = value, x = Status1, fill = Rescan)) + geom_bar(position = "dodge", width=0.7, stat = "identity") + labs(y = "percentage", x = "Status") + scale_fill_manual(values = c("green", "red", "orange1")) + theme(text=element_text(size=15)) + scale_y_continuous(labels = scales::label_percent(scale = 1, accuracy = 1), limits = c(0,100))
what I want with this plot are a few things:
- the actual percentage value displayed on top of each of the 6 bars in black
- The order of the bars changed - its currently 'no' ,' uncertain' and then 'yes'. I want it changed to 'no', ' yes' and then uncertain.
I've tried the Geom_text and also the geom_label but failed to achieve '1'. I've tried 'reorder' for '2' but even that doesnt seem to work.
Any solution for the above please. Many thanks.