title: geom_density() grouped plot with discrete x axis is not smooth
body: <p>I was working with a dataset that consists of two different groups of observations where the value is an integer.  I wanted to plot the density of these to get a sense for how the different groups are distributed over the values.  </p>
  
  <p>What happened was one group had a 'smooth' density while the other had a 'wavy' density.  I know this has something to do with bandwidth and the fact that my data is basically tied to discrete observations but I would love if someone can explain exactly why.</p>
  
  <p>Here's an example:</p>
  
  <pre><code>data2 &lt;- rbind(
      data.frame(group=rep('poisson1', 1000), value = rpois(1000, 5)),
      data.frame(group=rep('poisson2', 1000), value = rpois(1000, 45)))
  
  library(ggplot2)
  ggplot(data2, aes(x=value, fill=group)) +
    geom_density()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/MgzDh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MgzDh.png" alt="enter image description here"></a></p>
  
  <p>And strangely, I can create that dataframe again to get a new sample, and the plot sometimes is smooth:
  <a href="https://i.stack.imgur.com/SEDj4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SEDj4.png" alt="enter image description here"></a></p>