I want to make a plot with days in x axis from the forecast process. I made an example using the guides from here: https://stackoverflow.com/a/10347205/2366057
The example from the link:
Lines <- "Date Used
2011-11-1/00:00:00 587
2011-11-2/01:00:00 578
2011-11-3/02:00:00 600
2011-11-4/03:00:00 599
2011-11-5/04:00:00 678
2011-11-6/05:00:00 555
2011-11-7/06:00:00 650"
dm <- read.table(text = Lines, header = TRUE)
x = dm
require(lubridate)
library(forecast)
y = ts(x$Used, start=c(2011, yday("2011-11-01")), frequency=365)
fcast = forecast(ets(y), 10)
plot(fcast, xaxt="n")
a3 = strptime(x$Date, "%Y-%m-%d/%H:%M:%S")
axis(1, at = decimal_date(a3), labels = format(a3, "%Y-%b-%d %H:%M:%S"), cex.axis=0.3, las=2)
My data:
"day","price"
"2010-02-12 00:00:00",12
"2010-02-12 01:00:00",14
"2010-02-12 02:00:00",15
"2010-02-12 03:00:00",14
"2010-02-12 04:00:00",13
"2010-02-12 05:00:00",16
I have my data into a csv file and as the above:
df = read.csv(filepath, header=TRUE, sep=",")
require(lubridate)
library(forecast)
y = ts(df$price)
fcast = forecast(ets(y), 10)
plot(fcast, xaxt="n")
a3 = strptime(df$day, "%Y-%m-%d %H:%M:%S")
axis(1, at = decimal_date(a3), labels = format(a3, "%Y-%b-%d %H:%M:%S"), cex.axis=0.6, las=2)
In the second snippet in the x-axis the days doesn't appear. What is it wrong?
Thank you in advance.