smartEllipsis: Employ an ellipsis, if necessary

View source: R/smartEllipsis.R

smartEllipsisR Documentation

Employ an ellipsis, if necessary

Description

Employ an ellipsis, if necessary

Usage

smartEllipsis(strings, max = 2, tail = 1, empty = "None")

Arguments

strings

Vector of strings to be joined (character)

max

Number of strings before ellipsis (integer)

tail

Number of strings after the ellipsis (integer, optional)

empty

Returned if strings is empty (character)

Value

All the strings pasted together, separated by commas, up to a maximum of max strings; if strings has more than max elements, the extra elements are replaced by an ellipsis. If strings is empty, then empty is returned.

Examples

smartEllipsis(c("tom", "dick", "harry", "peter"), 4)
smartEllipsis(c("tom", "dick", "harry", "peter"), 3)
smartEllipsis(c("tom", "dick", "harry", "peter"), 3, tail = 0)
smartEllipsis(c("tom", "dick", "harry", "peter"), 2)
smartEllipsis(c("tom", "dick", "harry", "peter"), 2, tail = 0)
smartEllipsis(character(0), 3)


pteetor/tutils documentation built on May 5, 2024, 10:17 a.m.