ggplot2 bar chart text listing every variable instead of total

Hi,

I have made a bar chart using ggplot2 showing how many employees there are in different sectors. However, when I try to add the total within each bar, it takes each variable of the Employees data instead of the total. How would I get the sum?

This is my code:


library(ggplot2)
ggplot(df, aes(x = Industry_broad, y = Employees, fill = Industry_broad)) + 
  geom_bar(stat = "identity") + theme_minimal() + theme(legend.position="none") + 
  geom_text(aes(label=Employees), position=position_dodge(width=0.9), vjust=-0.25)

ยดยดยด

Please provide a reprex.
We don't have df.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.