I have this plot and I would like to have the bars in reverse order (flying, poison,..., dark, bug). I've tried some of the solutions here and so far I can only sort them in this order.
This is the data
> bug_dual_type
dataset.Type.1 dataset.Type.2 Freq
1              Bug            Bug    0
19             Bug           Dark    0
37             Bug         Dragon    0
55             Bug       Electric    2
73             Bug          Fairy    0
91             Bug       Fighting    1
109            Bug           Fire    2
127            Bug         Flying   13
145            Bug          Ghost    1
163            Bug          Grass    6
181            Bug         Ground    1
199            Bug            Ice    0
217            Bug         Normal    0
235            Bug         Poison   11
253            Bug        Psychic    0
271            Bug           Rock    3
289            Bug          Steel    5
307            Bug          Water    1
This is my code:
bug_dual_type<-types_table_complete[types_table_complete$dataset.Type.1 == "Bug", ]
bug_dual_type
bug_dual_type$ordered_Levels <- reorder(bug_dual_type$dataset.Type.2, (bug_dual_type$Freq))
ggplot(bug_dual_type,aes(x=(ordered_Levels), y = Freq)) + geom_bar(binwidth=1, stat="identity", fill="#E69F00")
And the plot:

Thanks.