I am trying to plot the SP500 Index near the 2004 Presidential Elections.
The data are:
Date SP500
2004-05-01 1103
2004-06-01 1133
2004-07-01 1106
2004-08-01 1089
2004-09-01 1118
2004-10-01 1117
2004-11-01 1169
2004-12-01 1199
2005-01-01 1181
My code is the following:
library(ggplot2)
library(ggthemes)
library(lubridate)
ggplot(data_2004 , aes(x = Date, y = SP500)) +
geom_path(color = "red", size = 2) +
theme_economist() +
ggtitle("S&P 500 Index Tumbles because of US Presidential Elections") +
ylab("SP500 Index") +
xlab("Date") +
scale_x_continuous(
breaks = data_2004$Date,
labels = c('5/2004', '6/2004', '7/2004','8/2004', '9/2004', '10/2004',
'11/2004', '12/2004', '1/2005'))
I get the following exception:
ERROR while rich displaying an object: Error in as.Date.numeric(value): 'origin' must be supplied