title: Separating Lines with ggplot (geom_line) when using stat='count'
body: <p>I currently have some data that is basically a factor and a date. Here is a simplified idea of it.</p>
  
  <pre><code>date &lt;- c(1901,1901,1901,1902,1902,1902,1901,1903,1902,1904,1902,1903,1903,1904,1905,       1901,1903,1902,1904,1902,1902,1903,1904,1902,1902,1901,1903,1903,1904,1905, 1905,1906,1907,1908,1901,1908,1907,1905,1906,1902,1903,1903,1903,1904,1905,1901,1901,1901,1902,1902,1902,1901,1903,1902,1904,1902,1903,1903,1904,1905,
  1901,1903,1902,1904,1902,1902,1903,1904,1902,1902,1901,1903,1903,1904,1905,
  1905,1906,1907,1908,1901,1908,1907,1905,1906,1902,1903,1903,1903,1904,1905,
  1905,1906,1907,1908,1901,1908,1907,1920,1920,1920,1921,1921,1921,1921,1921)
  
  genre &lt;- sample(c("fiction","nonfiction"),105,replace=TRUE)
  data &lt;- as.data.frame(cbind(date,genre))
  # I know this is not an ideal way to coerce to a numeric 
  data$date &lt;- as.numeric(as.character(data$date))
  </code></pre>
  
  <p>So far, so good. As you'll note if you plot it it, though, there is a big gap in the data which the line obscures. This plot will illustrate.</p>
  
  <pre><code>library(ggplot2)
  ggplot(data,aes(x=date,color=genre)) + geom_line(stat='count')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/YNe40.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YNe40.png" alt="Example Plot 1."></a></p>
  
  <p>I have seen <a href="https://stackoverflow.com/questions/14821064/line-break-when-no-data-in-ggplot2">this post</a> which suggests adding a group, which I can do.</p>
  
  <pre><code>data$group &lt;- ifelse(data$date &lt; 1910,1,2)
  ggplot(data,aes(x=date,color=genre,group=group)) + geom_line(stat='count')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/8aaet.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8aaet.png" alt="Example Plot 2"></a></p>
  
  <p>So there appears to be no way to preserve the color aesthetics I want for my output <strong>and</strong> specify a <code>group</code>, <em>while</em> using <code>stat='count'</code>. This plot, for instance, nicely shows the gap in the data, but loses the color/distinction based on the <code>genre</code> factor:</p>
  
  <pre><code>ggplot(data,aes(x=date,color=genre,group=group)) + geom_line(stat='count')
  </code></pre>
  
  <p>So, is this not possible? Am I missing something? Is there a better way to do this, or do I need to <code>summarize</code> or otherwise mutate my date so that I don't rely on <code>stat='count'</code> at the plotting stage? </p>