list_to_chr: Simple list to character

Description Usage Arguments Details Value Examples

View source: R/list_chr.R

Description

Returns a text representation of a list, whose lower level elements are atomic vectors.

Usage

1
2
3
4
5
6
7
list_to_chr(
  x,
  atom_sep = ";",
  list_sep = "|",
  simplify_threshold = Inf,
  simplify_sep = "->"
)

Arguments

x

a list, whose lower level elements are atomic vectors.

atom_sep

separator for the elements of atomic vectors.

list_sep

separator for the elements of lists.

simplify_threshold

non-negative number of atomic elements from which the character string is simplified (only first and last elements separated by a separator, "->" by default).

simplify_sep

a separator (one or several characters) if the string has to be simplified.

Details

Even if the list has several hierarchical levels, the returned value is always a string. To preserve a complex hierarchy, use lapply or purr::map_chr at a given hierarchical level.

Value

A string, the text representation of x.

Examples

1
2
list_to_chr(list(letters[1:2], 1:3, 4))
list_to_chr(list(letters, LETTERS), simplify_threshold = 10)

the-knife/listchr documentation built on July 28, 2020, 4:16 a.m.