Features:
custom separator (
sep),custom separator for length-two input (
sep2),custom last separator (
last),adds ellipsis to truncated strings,
uses Unicode ellipsis character on UTF-8 console,
can collapse "from both ends", with
style = "both-ends",can consider a limit for the display width of the result, in characters,
handles ANSI control sequences correctly when measuring display width.
Arguments
- x
Character vector, or an object with an
as.character()method to collapse.- sep
Separator. A character string.
- sep2
Separator for the special case that
xcontains only two elements. A character string. Defaults to the value oflastwithout the serial comma.- last
Last separator, if there is no truncation. E.g. use
", and "for the serial comma. A character string.- trunc
Maximum number of elements to show. For
style = "head"at leasttrunc = 1is used. Forstyle = "both-ends"at leasttrunc = 5is used, even if a smaller number is specified.- width
Limit for the display width of the result, in characters. This is a hard limit, and the output will never exceed it. This argument is not implemented for the
"both-ends"style, which always usesInf, with a warning if a finitewidthvalue is set.- ellipsis
Character string to use at the place of the truncation. By default, the Unicode ellipsis character is used if the console is UTF-8, and three dots otherwise.
- style
Truncation style:
both-ends: the default, shows the beginning and end of the vector, and skips elements in the middle if needed.head: shows the beginning of the vector, and skips elements at the end, if needed.