Lets say this is my df :
people <- c(1,1,1,2,2,3,3,4,4,5,5)
activity <- c(1,1,1,2,2,3,4,5,5,6,6)
completion <- c(0,0,1,0,1,1,1,0,0,0,1)
And I would like to remove all people that never completed any activity.
I have tried this code, but somehow it does not work. I have no idea what could be wrong here.
nevercompleted<- df %>%
filter(completion != 0) %>%
group_by(people) %>%
summarise("frequency activity" = n())
df<- -c (df$nevercompleted)
So, in this scenario person 4 should be removed from the df. Note that I am only intrested in removing those that never completed anything like person 4, not person 1 who at one point completes an activity.