I have a dataframe with one observation per row and two observations per subject. I'd like to filter out just the rows with duplicate 'day' numbers.
ex <- data.frame('id'= rep(1:5,2), 'day'= c(1:5, 1:3,5:6))
The following code filters out just the second duplicated row, but not the first. Again, I'd like to filter out both of the duplicated rows.
ex %>%
group_by(id) %>%
filter(duplicated(day))
The following code works, but seems clunky. Does anyone have a more efficient solution?
ex %>%
group_by(id) %>%
filter(duplicated(day, fromLast = TRUE) | duplicated(day, fromLast = FALSE))