0

I have a data-frame like this:

C1 C2
A  Y
A  N
B  Y
C  Y
A  Y
D  N
E  Y
D  Y

using this code

ggplot(df,aes(x=C1,fill=C2) + geom_bar() + coord_flip() + xlab("C1")+ylab("Frequncy")

I can make stacked barchart but it shows frequency. stacked chart like here which shows proportion of frequency of c2 for each c1 value.

EDIT: I did not find any similar question as I am looking to show proportional stacked barchart in a away that each bar has 100 percent and divided in two part based on percentage of frequency of C2 for value of C1. for example for A, we have 2 Y and 1 N. So I want a bar that shows (66% Y and 33% N for A) and similar for other values in C1.

Sajjad
  • 67
  • 2
  • 8

0 Answers0