r - Violin Plot (geom_violin) with aggregated values -


i create violin plots aggregated data. data has category, value coloumn , count coloumn:

data <- data.frame(category = rep(letters[1:3],3),                    value = c(1,1,1,2,2,2,3,3,3),                    count = c(3,2,1,1,2,3,2,1,3)) 

if create simple violin plot looks this:

plot <- ggplot(data, aes(x = category, y = value)) + geom_violin() plot 

http://www.ahschulz.de/pub/overflow/violin_plot.png

that not wanted. solution reshape dataframe multiplying rows of each category-value combination. problem counts go millions takes hours plotted! :-(

is there solution data?

thanks in advance!

you can submit weight when calculating areas.

plot2 <- ggplot(data, aes(x = category, y = value, weight = count)) + geom_violin() plot2 

you warning messages weights not add one, ok. see here similar/related discussion.

enter image description here


Comments