| singleize {filesstrings} | R Documentation |
If a string contains a given pattern duplicated back-to-back a number of times, remove that duplication, leaving the pattern appearing once in that position (works if the pattern is duplicated in different parts of a string, removing all instances of duplication). This is vectorized over string and pattern.
singleize(string, pattern)
string |
A character vector. The string(s) to be purged of duplicates. |
pattern |
A character vector. Pattern(s) specified like the pattern(s)
in the stringr package (e.g. look at |
The string with the duplicates fixed.
singleize("abc//def", "/")
singleize("abababcabab", "ab")
singleize(c("abab", "cdcd"), "cd")
singleize(c("abab", "cdcd"), c("ab", "cd"))