this is pretty straightforward but seems to be complicated in other posts that I've read. Posts related to this question are fairly old, so wondering if there is now a more efficient way to go about this.
I have created a simple stacked bar chart using ggplot in R. But I can't figure out how to place the labels properly. This is what I have currently after playing around for awhile.
cplot$label = paste0(cplot$percentage*100, "%")
cplot
ggplot(cplot, aes(y=percentage, x=Diagnosis,fill=DrugCode)) +
geom_bar(position="fill", stat="identity",color="black") +
geom_text(aes(label = label,y=percentage),size=3.5,position=position_stack(vjust=2))
No luck in adjusting either, how can I just have the labels placed where they should be?