listcol_to_chr: List-columns to character (for a data frame)

Description Usage Arguments Value Examples

View source: R/list_chr.R

Description

Convert all list-columns of a data frame into character vectors.

Usage

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

Arguments

df

a data frame containing list-columns.

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.

Value

A data frame. Simple columns (atomic) remain the same, list-columns (recursive) are transformed into character vectors.

Examples

1
2
3
4
df <- data.frame(x = 1:2)
df$y <- list(letters[1:3], 1:2)
df$z <- list(list(3:4, 5:7), "d")
listcol_to_chr(df)

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