1
我有一些数据,我试图通过平滑(Loess,LM,无论)叠加在其类型上进行绘制。生成代码如下:来自ggplot2的qplot中的平滑错误
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)))
我没有问题,要么做一个多面的情节,或绘制顺利,但我cannnot一举两得。下面的前三行代码正常工作。第四行是我遇到麻烦:
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()
它提供了以下错误:
Error in
[<-.data.frame
(*tmp*
, var, value = list(NA
= NULL)) : missing values are not allowed in subscripted assignments of data frames
我缺少的是叠加平滑的面的情节?我可以发誓我以前做过这个,甚至可能用相同的数据。
在过去2周内下载了ggplot2。我认为错误可能是由于其中一个类型只有一条记录而导致的,因此不允许使用loess()或lm()来正确计算。计算testFrame如下所示。 testFrame < - data.frame(Time = sample(20:60,50,replace = T),Dollars = round(runif(50,0,6)),Type = c(rep(“Second”,10) (c(“First”,“Third”,“Fourth”),40,replace = T,prob = c(.33,.34,.33)))) 或者你可以简单地将“第二个“要采样的类型。 – Jared 2010-06-02 03:43:47
该数据集仍适用于我。 – hadley 2010-06-10 14:13:27