Sorry, mara, for not being clear enough. jrlewi’s approach is working perfectly fine, and indeed, that’s how I was doing it myself until now. What I am intrested in, is whether there is another - more convenient (less code) - way of doing it, by letting ggplot2 do the calculations for the proportions (and not doing it manually or with other functions).
You helped by giving me some time to think about it again, and try to figure out, how it’s done with counts. I found an answer by hadley https://github.com/tidyverse/ggplot2/issues/1531 and adapted it to proportions.
This solved my problem.
ggplot(diamonds, aes(factor(cut), y = ..prop.., group = 1)) +
geom_text(stat = "count",
aes(label = round(..prop.., 2), y = ..prop.. + 0.02))
Btw: In my previous attempts to solve this problem, I forgot to change the stat argument in geom_text to “count” and therefore got the error "Error in FUN(X[[i]], …) : object ‘prop’ not found"
I forgot that the default value for stats is “identity”.