I'm trying to plot the following data set in R:
fruit<-matrix(c("Apple","186","Banana","93","Elderberry","48","Durian", "28","Cherry", "28"),ncol=2,byrow=TRUE)
colnames(fruit) <- c("Name","Freq")
fruit <- data.table(fruit)
fruit$Freq <- as.numeric(as.character(fruit$Freq))
qplot(fruit$Name, fruit$Freq, geom="bar", stat="identity") + coord_flip()
But it's being plotted in alphabetical order
I want the barplot to show the fruit from highest frequency value to lowest. So Apple at the top of the Y axis, then Banana, etc...:
Apple 186
Banana 93
Elderberry 48
Durian 28
Cherry 28
I've tried to play with factors and levels but can't figure it out.