A convenience function to format atomic vectors as a written list.

listr(x, sep = ", ", conj = " and ", lim = Inf)

Arguments

x

atomic vector.

sep

Separator.

conj

Final separator.

lim

Elements to include in the list. Other elements are abbreviated to " ...".

Value

character.

Examples

listr(1:5)
#> [1] "1, 2, 3, 4 and 5"
listr(1:5, sep = "; ")
#> [1] "1; 2; 3; 4 and 5"
listr(1:5, sep = "; ", conj = " and")
#> [1] "1; 2; 3; 4 and5"
listr(1:5, sep = "; ", conj = " and", lim = 2)
#> [1] "1; 2 ..."