Extract all rows containing first value for each unique value of another column
问题 I am looking for something similar to this Select only the first rows for each unique value of a column in R but I need to keep ALL rows containing the first values of year per ID. In ither words, I need to subset the dataset on the first year listed, by individual ID. IDs can have their first year in 1 2 or 3, and all of the rows in the first year should be retained. For example: ID <- c("54V", "54V", "54V", "54V", "56V", "56V", "56V", "59V", "59V", "59V") yr <- c(1, 1, 1, 2, 2, 2, 3, 1, 2,