I have a table in R looking like this. Columns are male and female. Rows are 4 variables with both a no & yes. The values are actually the proportions. So in column 1 the sum of value in row 1 and 2 sums up to 1, because this is the sum of proportions yes & no for variable 1.
propvars
prop_sum_male prop_sum_female
1_no 0.90123457 0.96296296
1_yes 0.09876543 0.03703704
2_no 0.88750000 0.96296296
2_yes 0.11250000 0.03703704
3_no 0.88750000 1.00000000
3_yes 0.11250000 0.00000000
4_no 0.44444444 0.40740741
4_yes 0.55555556 0.59259259
I want to created a stacked barplot for those 4 variables.
I used
barplot(propvars)
which gives me this:
But as you can see the distinction between male & female is correct, but he puts all variables on top of each other. And I need 4 different bars next to each other for the 4 variables, with every bar representing yes/no stacked on top of each other. So the Y-axis should go from 0-1 instead of from 0-4 like now.
Any hints on how to do this?