This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to create a percentage stack plot for unequal group size in R?

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?

This is the how the input looks like

rstudio biostatistics percentage stackplot

Please post data instead of images of the data.

n <- 6
dat1<- data.frame(id=1:n,
Group=sample(c("A", "B"), 6, replace = TRUE) , 
Drug1=sample(c("Yes", "No"), 6, replace = TRUE))

0 answers

No answers yet.

Log in to answer this question.