更新一下自己的问题,我想要在ggplot上按照y值总合大小排序我的x类别,以下code
#Data
hp=read.csv(textConnection(
"class,year,amount
a,99,100
a,100,200
a,101,150
b,100,50
b,101,100
c,102,70
c,102,80
c,103,90
c,104,50
d,102,90"))
hp$year=as.factor(hp$year)
#Plotting
p=ggplot(data=hp)
p+geom_bar(binwidth=0.5,stat="identity")+ #
aes(x=reorder(class,amount),y=amount,label=amount,fill=year)+theme()
#↑这边新加入reorder试图将amount依照class重排
结果:http://imgur.com/DYsMqwl
#↑发现c,b,d有按照sum(amount)降幂排列,但是a没有
想请问各位版友有无解决办法呢?恳请赐教