How can I add percentage labels to this stacked barplot, with each component of the stacked bars labeled with it's corresponding percentage?
ggplot(mtcars, aes(cyl, fill = factor(gear))) +
geom_bar(position = "fill") +
scale_y_continuous(labels = scales::percent)
Edit: Was able to add counts, but still am unable to convert this to percent
ggplot(mtcars, aes(cyl, fill = factor(gear))) +
geom_bar(position = "fill") +
scale_y_continuous(labels = scales::percent)+
geom_text(aes(label=stat(count)), stat='count', position='fill')