My violin plot produces an error when all values in the series are the same.
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
The first two plots work fine, the second two fail with:
Error in `$<-.data.frame`(`*tmp*`, "n", value = 3L) :
replacement has 1 row, data has 0
Is this a bug? Is there a work-around? Thanks
This is a bug in v1.0.1 and has already been fixed in the development version according to Hadley.