title: R - Add 0 occurrences in capture-recapture data
body: <p>I have capture-recapture data with variables Year, Date, ID, and Distance.moved such that:</p>
  <pre><code>&gt; head(df)
  Year  ID       Date     Distance.moved
  2012 2012-005  29-05-12  10
  2012 2012-006  30-05-12  22
  2013 2013-001  22-06-13  5
  2013 2013-002  23-06-13  6
  </code></pre>
  <p>I want to add 0 occurrences to the distance moved column, to get values for events where they did not move, such as:</p>
  <pre><code>Year  ID       Date     Distance.moved
  2012 2012-005  29-05-12  10
  2012 2012-005  30-05-12  0
  2012 2012-006  29-05-12  0
  2012 2012-006  30-05-12  22
  2013 2013-001  22-06-13  5
  2013 2013-002  22-06-13  0
  2013 2013-002  23-06-13  6
  2013 2013-001  23-06-13  0
  </code></pre>
  <p>So only adding 0s for dates that exist as events in the Date column, and have it grouped per year.</p>
  <p>I tried to add a binary 1,0 column for occurrences as such:</p>
  <pre><code>df_occ &lt;- df %&gt;%
          group_by(Date,Year, ID) %&gt;%
          summarize(occurrence=n()) %&gt;%
          as.data.frame()
  </code></pre>
  <p>but this just gives me occurrence values = 1 for all IDs</p>