ID <- c("A", "A", "A", "B", "B", "c")
Value <- c("blue", "blue", "green", "red", "orange", NA)
df <- tibble(ID, Value)
I have to group by the ID, keep the value of Value which is the most repeated
If the values are equal (ID == "B")
, I choose the first value
The value variable should look like :
Value_output <- c("blue", "blue", "blue", "red", "red", NA)