I have a dataframe with the number of male and female per category. I made the following stacked bar plot :
Except I cannot manage to add % value for each gender in each barplot's category. Here's my dataset :
Gender <- c("F", "M", "M", "M", "M","F","M","M","F","M")
Cat <- c("Cat1", "Cat1", "Cat2","Cat2","Cat2","Cat1","Cat3","Cat3","Cat2","Cat3")
Count <- c(13, 12, 91, 38, 14, 16, 17, 54, 45, 63)
df <- data.frame(Gender, Cat, Count)
And here's my code :
ggplot(df)+
aes(x = Cat, fill = Gender)+
geom_bar(position = "fill")+
xlab("Cat")+
ylab("Count")+
labs(fill = "Gender")+
scale_y_continuous(labels = scales::percent)
The difference from other questions, is that I don't have a y= defined. So I can't add geom_text(label = y).
Thank you in advance for your help.