I'm trying to create a grouped barplot with ggplot. However, my variables are based on absolute likelihood and I would like to change them into relative likelihood since my two Groups have a different number of rows, so I can just compare them nicely if I have relative likelihoods respectively for both Groups.
This is my Code:
A <- Wahlcombined %>%
dplyr::select(Atomenergie, .origin) %>%
ggplot(aes(x = (Atomenergie), fill = .origin))
A + geom_bar(aes(y = (..count..)/sum(..count..))) +
ggtitle("Einstellung zur Atomenergie Häufigkeiten")+
xlab("für Atomenergie - gegen Atomenergie")+
labs(fill = "Bundestagswahl")
With (aes(y = (..count..)/sum(..count..))) I try to create relative likelihoods. I do not get an error, but it just does not create an barplot, it just Shows the title and the axis labels. It works without (aes(y = (..count..)/sum(..count..))) but then I just get absolute likelihoods and can't really compare the two Groups.
Thank you very much!