自从将 ggplot2 更新到 1.0.1 后 facet_wrap 出错

Error with facet_wrap since updating ggplot2 to 1.0.1

我截取了一段代码,自上周我将 ggplot20.9.3 更新为 1.0.1 以来,它运行良好。

所以基本上这是一个可重现的例子:

df <- data.frame(values=rnorm(200000),
                 title=rep(seq(1,20), each=10000))
ggplot(df, aes(values)) + geom_histogram(binwidth=.08) + facet_wrap(~ title)
ggplot(df, aes(values)) + geom_histogram(binwidth=.05) + facet_wrap(~ title)

在版本 0.9.3 中,它适用于 binwidth=.05。现在它 returns 一个错误:

Error: arguments imply differing number of rows: 238, 207

我想知道如何以保存的方式计算binwidth,这样它就不会退出。标准设置其实不太合我的口味

还有很多我不完全理解的警告信息:

1: In loop_apply(n, do.ply) :
  position_stack requires constant width: output may be incorrect

提前致谢。

编辑

因为经过几次测试,它似乎有时对我有用,有时对我不起作用,我也使用种子使一切都可重现......但最后,即使有种子,有时也有用,有时却不行.

有没有人知道如何解决这个问题?更新之前我从来没有遇到过问题。这是完整的输出:

> set.seed(123)
> df <- data.frame(values=rnorm(200000),
+                  title=rep(seq(1,20), each=10000))
> ggplot(df, aes(values)) + geom_histogram(binwidth=.05) + facet_wrap(~ title)
Error: arguments imply differing number of rows: 188, 177
In addition: Warning messages:
1: In loop_apply(n, do.ply) :
  position_stack requires constant width: output may be incorrect
2: In loop_apply(n, do.ply) :
  position_stack requires constant width: output may be incorrect
3: In loop_apply(n, do.ply) :
  position_stack requires constant width: output may be incorrect
4: In loop_apply(n, do.ply) :
  position_stack requires constant width: output may be incorrect
5: In loop_apply(n, do.ply) :
  position_stack requires constant width: output may be incorrect
6: In loop_apply(n, do.ply) :
  position_stack requires constant width: output may be incorrect
> ggplot(df, aes(values)) + geom_histogram(binwidth=.08) + facet_wrap(~ title)
> set.seed(123)
> df <- data.frame(values=rnorm(200000),
+                  title=rep(seq(1,20), each=10000))
> ggplot(df, aes(values)) + geom_histogram(binwidth=.05) + facet_wrap(~ title)
There were 20 warnings (use warnings() to see them)
> ggplot(df, aes(values)) + geom_histogram(binwidth=.08) + facet_wrap(~ title)

如您所见,只有第一个 ggplot 命令出错。在重新创建相同的数据框后,它可以工作并且只产生一些警告。

也许有人知道如何缩小问题的范围?

看起来问题与 plyr 相关。更新到开发版本 1.8.2.9000 解决了这个问题。感谢@aosmith 指出这一点!

警告包括 In loop_apply(n, do.ply),这表明程序包 plyr 可能与正在发生的一切有关。当我加载包 plyr_1.8.2 时,我可以重现错误。

更新到当前开发版本,plyr_1.8.2.9000,解决了这个问题。