Learn R Programming

tractor.base (version 1.1.0)

implode: Create a character string by concatenating the elements of a vector

Description

Create a character string by concatenating the elements of a vector, using a separator and optional final separator.

Usage

implode(strings, sep = "", finalSep = NULL)

Arguments

strings
A vector, which will be coerced to mode character.
sep
A unit length character vector giving the separator to insert between elements.
finalSep
An optional unit length character vector giving the separator to insert between the final two elements.

Value

  • A character vector of length one.

See Also

paste

Examples

Run this code
implode(1:3, ", ")  # "1, 2, 3"
implode(1:3, ", ", "and ")  # "1, 2 and 3"
implode(1:2, ", ", "and ")  # "1 and 2"

Run the code above in your browser using DataLab