I am doing a project which requires to use ggplot2 to plot time series data. This is the data set I am using:
This is what I've done now:
library(ggplot2)
library(lubridate)
eur$Date <- as.Date(eur$Date)
ggplot(eur, aes(Date, EUR)) + geom_line()
And I got this very weird plot. Can someone help me fix the problem?
Edit - if your data is of class timeseries(ts) then you can use ggfortify's autoplot function and it will take care of the conversion for you.
If your data is not timeseries, then your date column may be factor or character.
If it is character convert with as.Date(foo)
If it is a factor then see below
well you need to scale your data. Can you elaborate on your explanation of what the data looks likes. This formatting might help you. I need better understanding of data though
@Niranja Gd's answer will not work, because
format
is no argument inscale_x_date
.The following approach should do the job: