I\'m plotting a categorical variable and instead of showing the counts for each category value.
I\'m looking for a way to get ggplot
to display the perc
If you want percentage labels but actual Ns on the y axis, try this:
library(scales)
perbar=function(xx){
q=ggplot(data=data.frame(xx),aes(x=xx))+
geom_bar(aes(y = (..count..)),fill="orange")
q=q+ geom_text(aes(y = (..count..),label = scales::percent((..count..)/sum(..count..))), stat="bin",colour="darkgreen")
q
}
perbar(mtcars$disp)