Use all possible levels of a factor to generate zero length() in an output
<p>I'd like to summarize and count the number of cases within a group and have the output place a zero in a group where no cases exist. For example:</p>

<pre><code>library(dplyr)

df &lt;- structure(list(Station = c("TR1", "TR1", "TR1", "TR1", "TR1", 
                           "TR1", "TR1", "TR1", "TR2", "TR2", "TR2", "TR2", "TR2", "TR2", 
                           "TR2"), Age = c(1, 1, 1, 2, 2, 3, 4, 4, 1, 1, 1, 1, 3, 4, 4), 
               WeightTurtles = c(21, 22, 20, 43, 32, 32, 27, 32, 21, 22, 
                                 20, 15, 32, 37, 34)), class = c("tbl_df", "tbl", "data.frame"
                                 ), row.names = c(NA, -15L), .Names = c("Station", "Age", "WeightTurtles"
                                 ))

df %&gt;%
  group_by(Station, Age) %&gt;%
  summarise(NumTurtles=length(WeightTurtles))
</code></pre>

<p>Here is the result:</p>

<blockquote>
<pre><code>  Station   Age NumTurtles
    (chr) (dbl)      (int)
1     TR1     1          3
2     TR1     2          2
3     TR1     3          1
4     TR1     4          2
5     TR2     1          4
6     TR2     3          1
7     TR2     4          2
</code></pre>
</blockquote>

<p>What I would like is a row included in the above output that looks like this:</p>

<blockquote>
<pre><code>5     TR2     2          0
</code></pre>
</blockquote>

<p>So that is, how do I include occurrences (or lack of occurrences as it were) for levels on a factor that have zero length. More generally, how do I tell R to use all possible levels of a factor to count length?</p>