Remove first occurrence of elements in a vector from another vector
问题 I have a character vector, including some elements that are duplicates e.g. v <- c("d09", "d11", "d13", "d01", "d02", "d10", "d13") And another vector that includes single counts of those characters e.g. x <- c("d10", "d11", "d13") I want to remove only the first occurrence of each element in x from the 2nd vector v . In this example, d13 occurs in x and twice in v , but only the first match is removed from v and the duplicate is kept. Thus, I want to end up with: "d09", "d01", "d02", "d13" I