I have this df
df<- data.frame(
document= c("A", "B", "A", "B"),
column1 = c(1, 2, 3, 4),
column2 = c(3, 3, 4, 4),
column3 = c(5, 6, 5, 6),
column4= c(1,1,1,1),
column5= c(1,2,1,2)
)
I need to select the columns that have not the same values grouped by "document". So in my df I need to choose only the column 3,4 and 5.
Why this doesnt work?
df %>%
group_by(document) %>%
select_if(~length(unique(.)) > 1)
It selects all the colunm except the 4