I have a question about plotting x axis in a certain order.
here is the sample data I am plotting:
year names count
1 1998 allmylife - kcijojo 83
2 1997 doowopthatthing - laurynhill 196
3 1998 gettinjiggywitit - willsmith 231
4 2000 idontwanttomissathing - aerosmith 82
5 1998 imyourangel - rkelly 121
6 2013 myall - mariahcarey 70
Here is my code:
library(ggplot2)
setwd("C:/Users/Andrew/Desktop/music lyrics")
data = read.csv("summary.csv", header=FALSE, stringsAsFactors = FALSE)
names(data) = c('year', 'names', 'count')
ggplot(data, aes(names,count, fill=year))+
geom_bar(stat='identity')+
theme(axis.text.x = element_text(angle = 90, hjust = 1))
And here is my current plot:
How do I sort the x axis such that it starts from 1998, 1999, 2000....2014? (instead of plotting them in random years)