Learn R Programming

rmdHelpers (version 1.3.1)

printList: Print nice lists

Description

Generate a list formatted for printing from a vector.

Usage

printList(toPrint = letters[1:3], finalSepWord = "and", midSep = ",")

Value

Character vector of length 1 with the values of toPrint concatenated and separated as specified in the text.

Arguments

toPrint

Vector that you want to turn into a text list.

finalSepWord

The last word to include, defaults to "and" but could be "or" or similar

midSep

Separator between items, defaults to ","

Author

Mark Peterson

Details

Note that this function includes an Oxford comma.

Examples

Run this code
printList()

printList(LETTERS[1:5])

printList(letters[1:5], "or", ";")

Run the code above in your browser using DataLab