chr_to_list: Separated character to list

Description Usage Arguments Details Value Examples

View source: R/chr_list.R

Description

Convert a string into list, given separators.

Usage

1
chr_to_list(chr, atom_sep = ";", list_sep = "|")

Arguments

chr

string to convert.

atom_sep

separator for the elements of atomic vectors.

list_sep

separator for the elements of lists.

Details

The function is vectorized hence chr can be a character vector with more than one element. Consequently the returned value is always a list (even of length 1). If all elements of the returned list are atomic, the list is simplified.

Value

A list (NULL if the string is empty or NA).

Examples

1
2
3
4
5
chr_to_list("1;2;3|a;b")
chr_to_list("1;2;3")
chr_to_list("1|2|3")
chr_to_list(c("1;3", "2|4")) # vectorized usage
chr_to_list(c("1;3", "2;4")) # simplification

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