when I am using the following code, I get the percentage of 100% for each group. But I want it to be 100% overall. Each time should be as long as percentage-bar as they are represented in the whole variable.
So 20:00 (n=3) should account for 43%, 21:00 (n=2) for 29 % and so on.
DF <- data.frame(time = c("20:00", "22:00", "23:00", "21:00", "21:00", "20:00", "20:00"),
group = as.factor(c("early", "late", "late", "early", "early", "early", "early")))
library(ggplot2)
ggplot(data = DF, aes(x = time, y = stat(prop), fill = factor(..group..), group = group))+
geom_bar()
How to do that? Thanks in advance!