paste.unique.string <- function(x, sep = "/")
{
## Purpose: Put unique elements of a string vector into one long string.
## Arguments:
## x: a string vector
## sep: what separator to use when pasting all unique elements together.
## Return: a single string with unique elements of "x".
## Author: Feiming Chen, Date: 19 Jun 2017, 14:00
## ________________________________________________
paste0(unique(x), collapse = sep)
}
if (F) { # Unit Test
paste.unique.string(c("a", "b", "a", "b")) # "a/b"
}
Monday, June 19, 2017
Put unique elements of a string vector into one long string
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment