I managed to transform my initial dataset into this form:
ElemId total_count coef_true coef_false coef_ratio
1 a1 2 2 0 1
2 a2 4 4 0 1
3 a3 1 1 0 1
4 a4 5 5 0 1
5 a5 1 1 5 1
6 a6 4 4 0 1
7 a7 4 4 3 1
8 a8 2 2 2 1
9 a9 3 3 1 1
10 a10 1 1 4 1
Right now what am I trying to achieve is to plot stacked bar chart showing the coef_true and coef_false on single bars using ggplot, while preserving order by coef_ratio. Is there a way to do it without further transforming the dataset?
EDIT. Modifying data is OK, although I tried using melt with melt(valves, measure.vars=c("init_true", "init_false"))
and the bar chart seems to loose ordering of coef_ratio.