R - delete consecutive (ONLY) duplicates
问题 I need to eliminate rows from a data frame based on the repetition of values in a given column, but only those that are consecutive. For example, for the following data frame: df = data.frame(x=c(1,1,1,2,2,4,2,2,1)) df$y <- c(10,11,30,12,49,13,12,49,30) df$z <- c(1,2,3,4,5,6,7,8,9) x y z 1 10 1 1 11 2 1 30 3 2 12 4 2 49 5 4 13 6 2 12 7 2 49 8 1 30 9 I would need to eliminate rows with consecutive repeated values in the x column, keep the last repeated row, and maintain the structure of the