I have a 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 above, with the breaks = variable, I would like for the order to be preserved, rather than placed in alphabetical order.
I am rendering with:
ggplot (data, aes(x=variable, weight=importance, fill=variable)) + geom_bar() + coord_flip() + opts(legend.position='none')
However, the ordering of the variable names is alphabetical, and not the order within the data frame. I had seen a post about using "order" in aes, but appears to have no effect.
I am looking to have a breaks ordering in-line with the "order" column.
There seems to be a similar question How to change the order of discrete x scale in ggplot, but frankly, did not understand the answer in this context.
dput
and add a small sample of the data to the end of your post (or else use a globally available dataset from thedatasets
package in base R). – Shanevariable
a character or a factor? – Joshua Ulrich