I have the below data in a spreadsheet where the tasks assigned for the students are listed.
df <- 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)
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
I used the below snippet but it does not seem to work. Any help is appreciated.
df %>% group_by(Task) %>%
summarize(
Count = nrow(df[df$Status == 'Completed',])
)
Edit: Updated the question to add the actual dataset instead of a screenshot.
See Question&Answers more detail:
os