How do I draw the sum value of each class (in my case: a=450, b=150, c=290, d=90) above the stacked bar in ggplot2? Here is my code:
#Data hp=read.csv(textCo
You can use the built-in summary functionality of ggplot2 directly:
ggplot2
ggplot(hp, aes(reorder(class, -amount, sum), amount, fill = year)) + geom_col() + geom_text( aes(label = stat(y), group = class), stat = 'summary', fun = sum, vjust = -1 )