I have a dataframe like this
ID <- c(\"A\",\"A\",\"A\",\"B\",\"B\",\"C\",\"C\") Measurement <- c (\"Length\",\"Breadth\",\"Breadth\",\"Breadth\",\"Leng
In dplyr, it would be
library(dplyr) df %>% group_by(ID) %>% filter(n_distinct(Measurement) > 1) ## ID Measurement Value ## ## 1 A Length 4.5 ## 2 A Breadth 6.6 ## 3 A Breadth 7.5 ## 4 B Breadth 3.3 ## 5 B Length 5.6