2

当系列中的所有值都相同时,我的小提琴图会产生错误。

library(ggplot2)
d1 <- data.frame(x=c("a","a","a","b","b","b"),y=c(1,2,2,1,2,1)) # Two series of three with different values through each series
d3 <- data.frame(x=c("a","a","a","b","b","b"),y=c(1,2,2,1,1,1)) # Two series of three, one series has all the same values
ggplot(data=d1) + geom_violin(aes(x=x,y=y))                     # This works
ggplot(data=d1) + geom_violin(aes(x=x,y=y), scale="count")      # This works
ggplot(data=d3) + geom_violin(aes(x=x,y=y))                     # This produces an error: replacement has 1 row, data has 0
ggplot(data=d3) + geom_violin(aes(x=x,y=y), scale="count")      # This produces an error: replacement has 1 row, data has 0

前两个地块工作正常,后两个地块失败:

Error in `$<-.data.frame`(`*tmp*`, "n", value = 3L) : 
  replacement has 1 row, data has 0

这是一个错误吗?有解决办法吗?谢谢

4

1 回答 1

2

这是 v1.0.1 中的一个错误,根据 Hadley 的说法已经在开发版本中修复。

于 2015-09-30T06:54:22.717 回答