enum_str | R Documentation |
Takes a vector or list and enumerates its elements in a single string. Convenience function combining wrap_chr()
and cli::ansi_collapse()
with slightly
differing defaults (last
defaults to the value of sep2
).
enum_str(
x,
sep = ", ",
sep2 = " and ",
last = sep2,
trunc = Inf,
width = Inf,
ellipsis = cli::symbol$ellipsis,
style = c("both-ends", "head"),
wrap = ""
)
x |
Character vector, or an object with an |
sep |
Separator. A character string. |
sep2 |
Separator for the special case that |
last |
Last separator, if there is no truncation. E.g. use
|
trunc |
Maximum number of elements to show. For |
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 |
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:
|
wrap |
Character sequence |
A character scalar.
Other string functions:
as_chr()
,
as_comment_str()
,
as_line_feed_chr()
,
as_str()
,
capitalize_first()
,
dsv_colnames()
,
escape_lf()
,
fuse_regex()
,
prettify_nr()
,
sentenceify()
,
wrap_chr()
# by default, `last` defaults to `sep2`
pal::enum_str(1:2)
pal::enum_str(1:3)
# input is optionally wrapped in a character sequence
pal::enum_str(letters[1:3],
wrap = "`")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.