str_flatten: Flatten a string

View source: R/flatten.R

str_flattenR Documentation

Flatten a string

Description

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

Usage

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

Arguments

string

character vector to flatten.

collapse

string to insert between each element.

last

(Optional) string use in place of final separator.

Value

Returns a character vector of length 1

Examples

str_flatten(letters)
str_flatten(letters, "-")

str_flatten(letters[1:5], ", ", ", and ")
str_flatten(letters[1:3], ", ", ", and ")
str_flatten(letters[1:2], ", ", ", and ")
str_flatten(letters[1], ", ", ", and ")
str_flatten(letters[0], ", ", ", and ")

csdaw/stringrb documentation built on Aug. 13, 2022, 10:55 p.m.