This is a summary function for strings: regardless of the length of the input, it always returns a single string.

str_flatten(string, collapse = "", last = NULL)

Arguments

string

Character to flatten.

collapse

String to insert between each piece.

last

Optional string use in place of final separator.

Value

A character vector of length 1

Examples

str_flatten(letters)
#> [1] "abcdefghijklmnopqrstuvwxyz"
str_flatten(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"

str_flatten(letters[1:5], ", ", ", and ")
#> [1] "a, b, c, d, and e"
str_flatten(letters[1:3], ", ", ", and ")
#> [1] "a, b, and c"
str_flatten(letters[1:2], ", ", ", and ")
#> [1] "a, and b"
str_flatten(letters[1], ", ", ", and ")
#> [1] "a"
str_flatten(letters[0], ", ", ", and ")
#> [1] ""