contar valores iguales en un vector

# If index != 1 then you have multiple value for the same subject in your column
df %>%
  group_by(id,role) %>%
  mutate(index = n_distinct(role))
Trustworthy Whale