I have a data as shown below:
Year PostNumber
2008 2
2009 116
2010 511
2011 1578
2012 2429
2013 1724
2014 1026
2015 648
2016 668
2017 546
2018 496
2019 427
2020 115
I want to plot barplot and a line together in the same plot to show the trend.
I refer to post and this gave me the plot as shown below
The code is as follows:
p<-ggplot(data=df, aes(x=PostYear, y=PostNumber)) +
geom_bar(stat="identity", width = 0.4, fill="#0CF7E0")+
geom_text(aes(label=PostNumber), vjust=0)
p+scale_x_continuous(breaks = 1:13, labels = df$PostYear) +
geom_line() +
geom_smooth(lty = 2)
the class of PostYear is numeric and PostNumber is integer.
i am looking for only barplot with labels and a trend line.