I have this database, which is grouped by the variables Pres and Pres_ti.
Pres Pres_ti count perc
1 CARD IMP ASSE 13 0.26530612
2 CARD IMP IAMC 34 0.69387755
3 CARD IMP SEGPRIV 2 0.04081633
4 CARD PRO ASSE 10 0.25641026
5 CARD PRO IAMC 27 0.69230769
6 CARD PRO SEGPRIV 2 0.05128205
I used it to make a bar plot with ggplot,
ggplot(g2, aes(x = factor(Pres), y = perc*100, fill = Pres_ti,
fct_reorder(perc)) ) +
geom_bar(stat="identity", width = 0.7)+
coord_flip()
With that code i made a graph which shows, within each category of pres, the share of the different Pres_ti categories.
I want to order the graph in order to get in the first place the bar where Pres_ti ASSE category has the highest percentage .
For example, in my data, CARD IMP should be first since ASSE percentage is 0.26>0.25
Any idea of how can i solve this problem?
Thanks