I have tried to add data labels that show the sum of y values for a given x category. Here is the code I used:
library(ggplot2)
gg <- ggplot(vgsales, aes(x = Genre, y = Global_Sales, fill = Genre)) +
geom_col() +
geom_text(aes(x = Genre, y = Global_Sales, label = Global_Sales), stat = "sum")
print(gg)
I would like to position the labels above each bar and show only the sum of all y values for a given x. How do I accomplish this?
Edit: I've attempted to use some of the guides mentioned and the result is this:
So the labels appear to be overlapping each other and reporting individual Global_Sales sums. Is there a way just to report the total Global_Sales by genre as a label?