Joins the elements of a character vector into one string.
Details
The stri_flatten(str, collapse='XXX') call
is equivalent to paste(str, collapse='XXX', sep='').
If you wish to use some more fancy (e.g., differing)
separators between flattened strings,
call stri_join(str, separators, collapse='').
If str is not empty, then a single string is returned.
If collapse has length > 1, then only the first string
will be used.
See also
The official online manual of stringi at https://stringi.gagolewski.com/
Gagolewski M., stringi: Fast and portable character string processing in R, Journal of Statistical Software 103(2), 2022, 1-59, doi:10.18637/jss.v103.i02
Other join:
%s+%(),
stri_dup(),
stri_join(),
stri_join_list()
Author
Marek Gagolewski and other contributors
Examples
stri_flatten(LETTERS)
#> [1] "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
stri_flatten(LETTERS, collapse=',')
#> [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"
stri_flatten(stri_dup(letters[1:6], 1:3))
#> [1] "abbcccdeefff"
stri_flatten(c(NA, '', 'A', '', 'B', NA, 'C'), collapse=',', na_empty=TRUE, omit_empty=TRUE)
#> [1] "A,B,C"
stri_flatten(c(NA, '', 'A', '', 'B', NA, 'C'), collapse=',', na_empty=NA)
#> [1] ",A,,B,C"