These function parsers characters into list and list into characters. They help to parse the argument and makes the user input easier and intutive.

chr2list(chr)

Arguments

chr

A character string that represents a list or a vector see Notes for details.

Value

A list or a vector

Note

A semicolon in the string separates the elements of a list while A comma in the string separates the elements of a vector. See example.

Examples

chr2list("1, 2, 3") # c(1, 2, 3)
#> [1] 1 2 3
chr2list("1, 2; 3, 4") # list(c(1, 2), c(3, 4))
#> [[1]] #> [1] 1 2 #> #> [[2]] #> [1] 3 4 #>
chr2list("1:2; 3:7") # list(1:2, 3:7)
#> [[1]] #> [1] 1 2 #> #> [[2]] #> [1] 3 4 5 6 7 #>
chr2list("1, 2, 3;") # list(c(1, 2, 3))
#> [[1]] #> [1] 1 2 3 #>