There is probably a faster way:
df %>%
group_by(id) %>%
arrange(stopSequence) %>%
filter(row_number()==1 | row_number()==n())
More Related Contents:
- Summarizing multiple columns with dplyr? [duplicate]
- Relative frequencies / proportions with dplyr
- How to create a lag variable within each group?
- Why are my dplyr group_by & summarize not working properly? (name-collision with plyr)
- Filter data frame by character column name (in dplyr)
- How to number/label data-table by group-number from group_by?
- Remove duplicated rows using dplyr
- dplyr summarise: Equivalent of “.drop=FALSE” to keep groups with zero length in output
- dplyr: “Error in n(): function should not be called directly”
- dplyr: inner_join with a partial string match
- Can dplyr summarise over several variables without listing each one? [duplicate]
- Change value of variable with dplyr
- sample rows of subgroups from dataframe with dplyr
- Assigning Dates to Fiscal Year
- filter function in dplyr errors: object ‘name’ not found
- Create a ranking variable with dplyr?
- How to pass dynamic column names in dplyr into custom function?
- Calculate group mean while excluding current observation using dplyr
- R – Group by variable and then assign a unique ID [duplicate]
- Emulate split() with dplyr group_by: return a list of data frames
- Sparklyr: how to center a Spark table based on column?
- R sum a variable by two groups [duplicate]
- Join two data frames in R based on closest timestamp
- Conditionally Count in dplyr
- data.table row-wise sum, mean, min, max like dplyr?
- Update/Replace Values in Dataframe with Tidyverse Join
- dplyr: put count occurrences into new variable [duplicate]
- Add row in each group using dplyr and add_row()
- How to replace certain values in a specific rows and columns with NA in R?
- Why does as_tibble() round floats to the nearest integer?