Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

glue_collapse

Collapse a character vector


Description

Collapses a character vector of any length into a length 1 vector.

Usage

glue_collapse(x, sep = "", width = Inf, last = "")

Arguments

x

The character vector to collapse.

sep

a character string to separate the terms. Not NA_character_.

width

The maximum string width before truncating with ....

last

String used to separate the last two items if x has at least 2 items.

Examples

glue_collapse(glue("{1:10}"))

# Wide values can be truncated
glue_collapse(glue("{1:10}"), width = 5)

glue_collapse(1:4, ", ", last = " and ")
#> 1, 2, 3 and 4

glue

Interpreted String Literals

v1.4.2
MIT + file LICENSE
Authors
Jim Hester [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.