make_unique | R Documentation |
Append sequence numbers to duplicate elements to make all elements of a character vector unique.
make_unique(xs, sep = "-") make_unique_duplicates(xs, sep = "-") make_unique_all(xs, sep = "-") make_unique_all_or_none(xs, sep = "-")
xs |
a character vector |
sep |
a character string used to separate a duplicate string from its sequence number |
make_unique
: Append a sequence number to duplicated elements, including the first occurrence.
make_unique_duplicates
: Append a sequence number to duplicated elements, except the first occurrence.
This function behaves similarly to make.unique
make_unique_all
: Append a sequence number to every element.
make_unique_all_or_none
: Append a sequence number to every element or no elements.
Return xs
unchanged if the elements of the character vector xs
are already unique.
Otherwise append a sequence number to every element.
make.unique
abcb <- c("a", "b", "c", "b") make_unique(abcb) make_unique_duplicates(abcb) make_unique_all(abcb) make_unique_all_or_none(abcb) make_unique_all_or_none(c("a", "b", "c")) x <- make_unique(abbreviate(state.name, 3, strict = TRUE)) x[grep("-", x)]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.