I am trying to create a stacked barplot in R to visualize differences in two groups.
My dataset looks like this:
A | User |
---|---|
ABC | Male |
DEF | Female |
GHI | Female |
XYZ | Female |
JKL | Male |
ABC | Male |
XYZ | Male |
XYZ | Female |
I would like the User
to be on the x-axis, the count or percentage of A
on the y-axis, and the categories of A
to be the stacks or the fill or the different groups.
Edit:
ggplot(data, aes(x=User, fill = A)) +
geom_bar(position = "fill") +
scale_fill_brewer(palette = "BrBG") +
labs(y = "Percent")
Is there a way to show the percent labels on the stacks?