I have problem in sorting x axis by y value in ggplot2: here is the code below
#Data hp=read.csv(textConnection( \"class,year,amount a,99,100 a,100,200 a,101
You need to give reorder the sum function, otherwise it defaults to using the mean function. Then, I put a - in front of amount to get the order reversed.
sum
mean
-
amount
p=ggplot(data=hp) p+geom_bar(binwidth=0.5,stat="identity")+ # aes(x=reorder(class,-amount,sum),y=amount,label=amount,fill=year)+ theme()