I have data.frame with entries like:
variable importance order
1 foo 0.06977263 1
2 bar 0.05532474 2
3 baz 0.03589902 3
4 alpha 0.03552195 4
5 beta 0.03489081 5
...
When plotting the chart above, with breaks = variable, I would like the order to be preserved, and not placed in alphabetical order.
I process with:
ggplot (data, aes (x = variable, weight = importance, fill = variable)) +
geom_bar () +
coord_flip () + opts (legend.position = 'none')
However, the order of the variable names is alphabetical, not the order in the data frame. I saw a message about using "order" in aes, but it seems to have no effect.
I am looking to have an interrupt order in a row with an order column.
It seems there is a similar question How to change the order of the discrete scale x in ggplot , but, frankly, did not understand the answer in this context.
r ggplot2
Jonathan Shore Oct 22 '10 at 20:22 2010-10-22 20:22
source share