str_coll: Collapse a vector into a string

View source: R/string_tools.R

str_collR Documentation

Collapse a vector into a string

Description

Take the elements of multiple vectors and concatenate them into one long string.

Usage

str_coll(..., wrap = "", between = ",", unique = FALSE)

Arguments

...

(...) Vectors that will be concatenated and coerced to Character.

wrap

(Character) Placed at the left and right sides of each vector element.

between

(Character) Placed between each element of the original vector(s).

unique

(Logical) If TRUE, duplicate entries in ... will be removed.

Value

A string.

Authors

Examples

## Not run: 
vec <- c("Gum", "Rock", "Pen", "Bottle", "Pen")

str_coll(vec)
#> [1] "Gum,Rock,Pen,Bottle,Pen"

str_coll(vec, wrap = "-", between = ", ")
#> [1] "-Gum-, -Rock-, -Pen-, -Bottle-, -Pen-"

str_coll(vec, wrap = "-", between = ", ", unique = TRUE)
#> [1] "-Gum-, -Rock-, -Pen-, -Bottle-"

## End(Not run)


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.