I recently created a plot using geom_density and it is really informative about the topic I am studying. However, some of my collaborators worry about the use of density on the y-axis rather than say frequency or raw count because density t is not something that is usually reported in my field. I have spent some time trying to develop a plot using other geom's such as, geom_bar, geom_freqpoly, and geom_area, but really haven't come up with something as nice as the geom_density plot. Nice as in I really like how smooth the overlapping distributions look with geom_density. The others look clunky or jagged. Does anyone have any suggestions on how to make a plot similar to geom_density, but instead of density on the y axis have frequency instead?
Below is some example code to get you started.
date <- abs(round(c(rnorm(n=100,mean=5,sd=1),rnorm(n=50,mean=15,sd=1))))
assign.type <- c(rep("Yes",times=100), rep("No",times=50))
tmp <- data.frame(cbind(date,assign.type))
library(ggplot2)
ggplot(tmp, aes(x=as.numeric(date),fill=assign.type))+
geom_density(alpha=0.8)
ggplot(tmp, aes(x=as.numeric(date),y=..count..,fill=assign.type, ymax=max(..count..+10)))+
geom_freqpoly(binwidth=5)
ggplot(tmp, aes(x=as.numeric(date)))+
geom_area(aes(y = ..count.., fill = assign.type, group = assign.type), stat = "bin",position="dodge")
ggplot(tmp, aes(x=as.numeric(date),fill=assign.type))+
geom_bar(position="dodge", binwidith=10)