I made the following graph using ggplot2. What I seek is to add labels with percentages to each of the bars.
cat.ocup.grafico<-ggplot(subset(casen8va, !is.na(o15)),
aes(factor(o15), weight=expr))+
geom_bar(aes(y =(..count..)/sum(..count..)), fill="blue")+
ylab("Porcentaje")+xlab("Categoría Ocupacional")+coord_flip()
To do that I tried with the following code. But for some reason, the bars are erased.
Can someone help me?
cat.ocup.grafico+geom_text(aes(label =ifelse((..count..)==0,"",
scales::percent((..count..)/sum(..count..)))),
stat="count",colour="darkgreen")