I found a script to make grouped barplots with ggplot. But I want it to label each bar with the count instead of the percentage.
I am using this code right now:
ggplot(data = subset(data, geb_nat!="nat" & !is.na(geb_use)),
aes(x = geb_typ, group = geb_use)) +
geom_bar(aes(y = ..prop.., fill = factor(..x..)), stat = "count") +
geom_text(aes(label = scales::percent(..prop..), y = ..prop.. ),
stat = "count", vjust = -.5) +
labs(y = "Percent", fill="geb_typ") +
facet_grid(~geb_use) +
scale_y_continuous(labels = scales::percent)
and this is the result:
I want to show the actual count on top of the bars not the percentage