r - 将 ggplot2 更新到 1.0.1 后出现 facet_wrap 错误

标签 r ggplot2

我截断了一个代码,自上周更新 ggplot2 以来它运行良好来自 0.9.31.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 一起使用.现在它返回一个错误:
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 命令会出现错误。在重新创建相同的数据框后,它可以工作并且只产生一些警告。

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

最佳答案

警告包括 In loop_apply(n, do.ply) , 表示包 胶合板可能会参与任何正在发生的事情。当我加载包时 plyr_1.8.2 我可以重现错误。

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

关于r - 将 ggplot2 更新到 1.0.1 后出现 facet_wrap 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30572637/

相关文章:

performance - R:为什么 [[ ]] 方法比使用 $ 更快地对列表进行子集化?

r - 如何将点添加到堆叠条形图

r - 暂时禁用 ggplot() 中已经定义的美学

r - dplyr 改变列范围的行列最大值

R:rpart 树使用两个解释变量生长,但在删除不太重要的变量后不再生长

r - 根据另一个数据框中的日期范围划分数据框中的值

r - 在 R 中进行子集化时是否需要包含 `which` 或者我可以进行逻辑测试吗?

r - 仅改变小平面之间的水平间距(ggplot2)

r - 如何使 geom_bar 中的闪避与 geom_errorbar、geom_point 中的闪避一致

R ggplot2 : Labeling a horizontal line without associating the label with a series