我有几个数据集类似于https://www.dropbox.com/s/j9ihawgfqwxmkgc/pred.csv?dl=0
从CSV加载它们,然后绘制工作正常
predictions$date <- as.Date(predictions$date)
plot(predictions$date, predictions$pct50)
但是,当我想用GGPLOT得出这些数据的预测点到情节将它们与原来的点状比较:
p = ggplot(theRealPastDataValues,aes(x=date,y=cumsum(amount)))+geom_line()
此命令
p + geom_line(predictions, aes(x=as.numeric(date), y=pct50))
生成以下错误:
ggplot2 doesn't know how to deal with data of class uneval
但作为第一个plot(predictions$date, predictions$pct50)
与数据打交道,我不明白什么是错的。
编辑
dput(predictions[1:10, c("date", "pct50")])
structure(list(date = c("2009-07-01", "2009-07-02", "2009-07-03",
"2009-07-04", "2009-07-05", "2009-07-06", "2009-07-07", "2009-07-08",
"2009-07-09", "2009-07-10"), pct50 = c(4276, 4076, 4699.93, 4699.93,
4699.93, 4699.93, 4664.76, 4627.37, 4627.37, 4627.37)), .Names = c("date",
"pct50"), row.names = c(NA, 10L), class = "data.frame")
编辑2
我改变了
p + geom_line(data = predictions, aes(x=as.numeric(date), y=pct50))
和错误更改为:
Invalid input: date_trans works with objects of class Date only
Zusätzlich: Warning message:
In eval(expr, envir, enclos) : NAs created
所以我认为,提示如何应对来自GGPLOT2错误“类uneval的数据”? (见注释)是个好主意,还是位积不起作用。