Collapse a character vector to a single string
Arguments
- strings
A character vector, where each element of the vector is a character string.
- separator
A character string to separate the concatenated elements. Defaults to an empty string, which results in no separation between elements.
See also
str_concat()
for concatenating multiple character strings/vectors together.
paste0()
which chr_collapse()
wraps around.
Examples
chr_collapse(c("Hello", "world"), " ")
#> [1] "Hello world"
chr_collapse(letters, "-")
#> [1] "a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z"
chr_collapse(1:9)
#> [1] "123456789"