Good afternoon, I want to create graphics using ggplot2, but not using the default sorting of the categorical variable (in alphabetical order, in script: letters), but using the associated value of the continuous variable (in script: number).
Here is an example script:
library(ggplot2) trial<-data.frame(letters=letters, numbers=runif(n=26,min=1,max=26)) trial<-trial[sample(1:26,26),] trial.plot<-qplot(x=numbers, y=letters, data=trial) trial.plot trial<-trial[order(trial$numbers),] trial.plot<-qplot(x=numbers, y=letters, data=trial) trial.plot trial.plot+stat_sort(variable=numbers)
The last line does not work.
Etienne Low-DΓ©carie
source share