Suppose I have a vector of numbers from 1:12 and want to plot them over period of time ranged from Jan. 2013 to Dec. 2013. I used the following code to generate the data and plotting:
dates<-seq(as.Date("2013/1/1"), by = "month", length.out = 12)
n<-seq(1:12)
df<-cbind(dates,n)
plot(df)
However, some problems come up with the last code; Firstly could not find an option in the first seq
to generate only months and year without day. Secondly, all dates in df
become serial even after adding as.Date
before dates
in cbind
. Finally, the x axis in the plot not in the time format as a result of the last two problems.