I am trying to get a boxplot to go from the factor with the lowest average to the ratio with the highest average. Here is a simple example:
a = rnorm(10,mean=3,sd=4) b = rnorm(10,mean=-1,sd=2) c = rnorm(10,mean=5,sd=6) d = rnorm(10,mean=-3,sd=1) e = rnorm(10,mean=0,sd=.5) labs = c(rep("a",10),rep("b",10),rep("c",10),rep("d",10),rep("e",10)) mean = c(rep(mean(a),10),rep(mean(b),10),rep(mean(c),10),rep(mean(d),10),rep(mean(e),10)) data = c(a,b,c,d,e) df = data.frame(labs,data,mean) df = df[order(df$mean),] boxplot(data~labs,data=df) #They are not ordered df$labs = ordered(df$labs, levels=levels(df$labs)) boxplot(data~labs,data=df) #It doesn't work
How can I get factors to order with the smallest on the left, increasing as I move to the right? There are several topics on this, but their approaches do not work for me. (maybe due to my data format?)
BONUS POINTS , helping me rotate the letters along the x axis 180 degrees.
Thanks in advance!