1

我有一些数据,我正在尝试按其类型绘制刻面,并叠加平滑(黄土、LM 等)。生成代码如下:

testFrame <- data.frame(Time=sample(20:60,50,replace=T),Dollars=round(runif(50,0,6)),Type=sample(c("First","Second","Third","Fourth"),50,replace=T,prob=c(.33,.01,.33,.33)))

制作多面图或绘制平滑图都没有问题,但我不能两者都做。下面的前三行代码工作正常。第四行是我遇到麻烦的地方:

qplot(Time,Dollars,data=testFrame,colour=Type)
qplot(Time,Dollars,data=testFrame,colour=Type) + geom_smooth()
qplot(Time,Dollars,data=testFrame) + facet_wrap(~Type)
qplot(Time,Dollars,data=testFrame) + facet_wrap(~Type) + geom_smooth()

它给出了以下错误:

[<-.data.frame( *tmp*, var, value = list( = NULL)) 中的错误NA:数据帧的下标分配中不允许缺失值

在多面图中覆盖平滑我缺少什么?我可以发誓我以前做过,甚至可能使用相同的数据。

4

1 回答 1

1

这个对我有用。确定你有最新版本的 ggplot2 吗?

于 2010-06-02T02:29:23.950 回答