Let's say we create a bar graph where we want to show the percentage falling into a given category. I'm thinking of survey data and showing how many people responded to A, B, or C and doing this WITHOUT having to change the data.
Sample code:
data(mtcars)
ggplot(data=mtcars, aes(hp))+
geom_bar(aes(y = (..count..)/sum(..count..)), binwidth = 25) +
scale_y_continuous(labels=percent)
Now how do I add the percentage labels? I've tried a lot of different approaches and seen a lot of what people have posted, but have not had any luck.