In a ggplot (barplot) I want to have the percentages shown per "colour"/category and not overall

Viewed 29

My code right now is as following:

Plot1 <- ggplot (data=dat) + 
  geom_bar(position = "dodge", aes(x=indoor_allergies_diagnosed, y = after_stat(count/sum(count)), fill=symptomatic))

#symptomatic is a "0"/"1" variable, dat is a dataframe with 100+variables

And it gives me a barplot in which the percentage of all values in the plot is 100%, (symptomatic and non-symptomatic together). However I'm trying to get the percentages for symptomatic and non-symptomatic to each be 100%. (or for that matter for each category of "fill")

Is there an easy way to do so?

My Graph for reference

0 Answers
Related