I'm wanting to plot an xts object using ggplot2 but getting an error. Here is what I'm doing:
dates <- c("2014-10-01", "2014-11-01", "2014-12-01", "2015-01-01", "2015-02-01")value <- as.numeric(c(3, 4, 5, 6, 5))new_df <- data_frame(dates, value)new_df$dates <- as.Date(dates)new_df <- as.xts(new_df[,-1], order.by = new_df$dates)
Now I try to plot it using ggplot2:
ggplot(new_df, aes(x = index, y = value)) + geom_point()
I get the following error:
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 0, 5
I'm not quite sure what it is that I'm doing wrong.