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

最初の 2 つのプロットは正常に動作しますが、次の 2 つのプロットは次のように失敗します。

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 に答える