I have 2 groups namely "A" and "B" of unequal sample size. The size of "A" is 19 and the size of "B" is 15 total size of data being 34. They have a categorical variable named "Drug1" to indicate how many people of group A and B takes that drug so the values of the "Drug1" variables are YES and NO.
How do I create a percentage stack plot where I can show both groups and the number of people of each who take the drug and who do not take the drug in percentage stacked over each other? I would also like to annotate the percentage value in the bar
This is a sample of how the input looks like:
dat1<- data.frame(id=1:n,
Group=sample(c("A", "B"), 6, replace = TRUE) ,
Drug1=sample(c("Yes", "No"), 6, replace = TRUE))
I think this is what you want: