Create a String from Inputs
collapse_to_string.Rd
Creates a single string from one or more inputs with each value separated by
delim
.
Examples
# collapses individual vectors
collapse_to_string(1:10)
#> [1] "1|2|3|4|5|6|7|8|9|10"
# input order is preserved
collapse_to_string(1:2, letters[1:2])
#> [1] "1|2|a|b"
collapse_to_string(data.frame(x = 1:2, y = letters[1:2]))
#> [1] "1|2|a|b"
# factor levels are captured (instead of numeric placeholders)
collapse_to_string(factor(letters[1:2]), "c")
#> [1] "a|b|c"
# unique applies across all inputs, order is determined by first appearance
collapse_to_string(c(3, 1, 2), 1:4, unique = FALSE)
#> [1] "3|1|2|1|2|3|4"
collapse_to_string(c(3, 1, 2), 1:4, unique = TRUE)
#> [1] "3|1|2|4"