title: COUNTIF equivalent in dplyr summarise
body: <p>I have a data frame listing total students (Stu) and number of students per group (ID) who are taking part in an activity (Sub):</p>
  
  <pre><code>     ID   Stu   Sub
    (int) (int) (int)
  1   101    80    NA
  2   102   130    NA
  3   103    10    NA
  4   104   210    20
  5   105   180    NA
  6   106   150    NA
  </code></pre>
  
  <p>I would like to know the number of groups in size bands (>400, >200, >100, >0) who are either involved in an activity (Sub > 0), or not (Sub is.na)</p>
  
  <pre><code>output &lt;- structure(list(ID = c(101L, 102L, 103L, 104L, 105L, 106L), 
                         Stu = c(80L, 130L, 10L, 210L, 180L, 150L), 
                         Sub = c(NA,NA, NA, 20L, NA, NA)), 
                    .Names = c("ID", "Stu", "Sub"), 
                    class = c("tbl_df", "data.frame"), 
                    row.names = c(NA, -6L))
  
  temp &lt;- output %&gt;% 
  mutate(Stu = ifelse(Stu &gt;= 400, 400,
           ifelse(Stu &gt;= 200, 200,
               ifelse(Stu &gt;= 100, 100, 0
                   )))) %&gt;%
  group_by(Stu) %&gt;%
  summarise(entries = length(!is.na(Sub)),
            noentries = length(is.na(Sub)))
  </code></pre>
  
  <p>The results should be:</p>
  
  <pre><code>    Stu entries noentries
    (dbl)   (int)     (int)
  1     0       0         2
  2   100       0         3
  3   200       1         0
  </code></pre>
  
  <p>But I get:</p>
  
  <pre><code>    Stu entries noentries
    (dbl)   (int)     (int)
  1     0       2         2
  2   100       3         3
  3   200       1         1
  </code></pre>
  
  <p>How can I make the length function in the summarise act like a countif?</p>