title: Group data in one column based on a string value in another column using dplyr
body: <p>I have the below data in a spreadsheet where the tasks assigned for the students are listed.</p>
  
  <pre><code>df &lt;- data.frame(
  Student=c("A","A","A","A","B","B","B","C","D","D","D","D"),
  Task=c("Homework","Classwork","Assignment","Poster","Poster","Homework","Assignment","Homework","Classwork","Homework","Assignment","Poster"),
  Status=c("Completed","Pending","Not performed","Not performed","Completed","Not performed","Not performed","Completed","Completed","Pending","Pending","Pending"), 
  stringsAsFactors = FALSE)
  </code></pre>
  
  <p>I would like to group the data at task level and find the count for each task based on 'Status' being 'Completed'. Below is my expected output</p>
  
  <p><a href="https://i.stack.imgur.com/K4Zfx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K4Zfx.jpg" alt="Output"></a></p>
  
  <p>I used the below snippet but it does not seem to work. Any help is appreciated.</p>
  
  <pre><code>df %&gt;% group_by(Task)  %&gt;% 
           summarize(
               Count = nrow(df[df$Status == 'Completed',])
           ) 
  </code></pre>
  
  <p><b>Edit:</b> Updated the question to add the actual dataset instead of a screenshot.</p>