fold: Friendly printing of a multi-element vector

View source: R/vector_tools.R

foldR Documentation

Friendly printing of a multi-element vector

Description

Produces a readout like "January, February, and 10 others".

Usage

fold(vec, n = 2)

Arguments

vec

(Vector) The vector you want to print.

n

(Integer) The maximum number of vector elements to show.

Value

A character vector of length 1 containing the readout (or NA).

Authors

Examples

month.name
#> [1] "January"   "February"  "March"     "April"     "May"       "June"
#> [7] "July"      "August"    "September" "October"   "November"  "December"

fold(month.name)
#> January, February, and 10 others

fold(1:20, n = 5)
#> 1, 2, 3, 4, 5, and 15 others

fold(character(0), n = 1)
#> [1] NA

fold(1:10, n = 0)
#> [1] NA


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