I am using the ggplot2
package to plot a grouped bar chart. I am having a hard time trying to show the labels above each bars. It seems that my code is simply showing the sum of each group. It is may be important to point out that my dataframe df3
consist of only 3 categorical variables (hence why I am using count in the codes below).
ggplot(df3, aes(SubDept2, ..count..)) +
geom_bar(aes(fill = Attrition), position = "dodge")+
geom_text(aes(label=..count..),stat='count',position=position_dodge(0.9))+
theme_minimal()+
scale_fill_brewer(palette="Paired")+
labs(x="Sub Dept",y="Count")
Here is how my plot looks (cropped image):
Here is how my sample data (df3) looks like:
Attrition Dept SubDept2
Yes Administration Finance
Yes Operations F&B
Yes Operations F&B
No Operations Rooms Division