开发者

Smooth Error in qplot from ggplot2

I have some data that I am trying to plot faceted by its Type with a smooth (Loess, LM, whatever) superimposed. Generation code is below:

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)))

I have no problem either making a faceted plot, or plotting the smooth, but I cannnot do both. The first three lines of code below work fine. The fourth line is where I have trouble:

qplot(Time,Dollars,data=testFrame,colour=Type)
qplot(Time,D开发者_如何学Collars,data=testFrame,colour=Type) + geom_smooth()
qplot(Time,Dollars,data=testFrame) + facet_wrap(~Type)
qplot(Time,Dollars,data=testFrame) + facet_wrap(~Type) + geom_smooth()

It gives the following error:

Error in [<-.data.frame(*tmp*, var, value = list(NA = NULL)) : missing values are not allowed in subscripted assignments of data frames

What am I missing to overlay a smooth in a faceted plot? I could have sworn I had done this before, possibly even with the same data.


It works for me. Are sure you have the latest version of ggplot2?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜