Skip to content
Prev 370106 / 398503 Next

ggplot2 geom_bar arrangement

In the general case it is not possible to do as you ask because "Lab" can be duplicated. However, in your specific case it is unique in your data frame, so you just have to control the order of the factor labels instead of letting them be set up in the default manner. Of course, you have to be aware that sticking character vectors into data frames without using the stringsAsFactors argument (read the help on the data.frame function) means they get converted to factors automatically so that is where you have to take control. 

df <- data.frame( Lab=factor( Lab, labels=Lab ),valuex)