I am trying to compare subsetted rows of a dataframe from beginning to end (by order of the presented dataframe), and return a true or false if the rows are the same, adding the result of true or false as a new column called compare.
In this reprex I want to return false if the previous row is different than the current row but only for subset columns y3 and y4. The column result "compare" should be False, False, True, True, False, True, False, False, False, False
y1 <- c("T", "T", "T", "T", "T", "T", "F", "F", "F", "N")
y2 <- c("A", "B", "A", "B", "A", "B", "A", "B", "C", "D")
y3 <- c("T", "F", "F", "F", "T", "T", "F", "F", "F", "N")
y4 <- c("B", "B", "B", "B", "B", "B", "A", "B", "C", "B")
d <- data.frame(y1, y2, y3, y4)