Use dplyr to take first and last row in a sequence by group [duplicate]
问题 This question already has answers here : Subset panel data by group [duplicate] (3 answers) Closed 1 year ago . I'm trying to use dplyr to take the first and last rows of repeated values by group. I'm doing this for efficiency reasons, particularly so that graphing is faster. This is not a duplicate of Select first and last row from grouped data because I'm not asking for the strict first and last row in a group; I'm asking for the first and last row in a group by level (in my case 1's and 0