Reduce character to the non-repeating entries

Entries which are the same as the preceding one are replaced by empty character. The inverse of insert_duplicates().

remove_duplicates(x, group = NULL)

Arguments

x

character vector.

group

optional vector of the same lenght as x that can be coerced to a factor. If group is provided, duplicates are only removed within the same group.

Value

character of the same length as x.

Examples

if (FALSE) { # \dontrun{
remove_duplicates(c(1,1,1,2,2,2), group = NULL)
remove_duplicates(c(1,1,1,2,2,2), group = c(1,1,2,2,3,3))
} # }