For the following data
ds <- read.table(header = TRUE, text =\" id year attend 1 2007 1 1 2008 1 1 2009 1 1 2010 1 1 2011 1 8 200
Or you could use:
ds %>% group_by(id) %>% filter(attend=all(!is.na(attend))) #Source: local data frame [10 x 3] #Groups: id # id year attend #1 1 2007 1 #2 1 2008 1 #3 1 2009 1 #4 1 2010 1 #5 1 2011 1 #6 9 2007 2 #7 9 2008 3 #8 9 2009 3 #9 9 2010 5 #10 9 2011 5