How to create a percentage stack plot for unequal group size in R?
0
0
Entering edit mode
2.9 years ago

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 • 699 views
ADD COMMENT
2
Entering edit mode

Please post data instead of images of the data.

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

like this?

barplot

ADD REPLY

Login before adding your answer.

Traffic: 2838 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6