当一系列中的所有值相同时,geom_violin会产生错误

时间:2015-06-09 01:17:38

标签: r ggplot2 violin-plot

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

iscroll.on('beforeScrollStart', function() {
    scroll.disable();
});
iscroll.on('scrollEnd', function() {
    scroll.enable();
})

前两个情节工作正常,后两个情节失败:

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

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

1 个答案:

答案 0 :(得分:2)

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