Learn R Programming

NCmisc (version 1.2.0)

comma.list: Print out comma separated list of values in X, truncating if many (good for error messages)

Description

Often for nice presentation of error messages you wish to display a list of values. This adds commas between entries and will truncate the list above a length of 50 items with an ellipsis. Very simple but convenient function.

Usage

comma.list(X)

Value

string with entries separated by commas, and if long, entries skipped indicated by an ellipsis.

Arguments

X

a vector to be displayed

Examples

Run this code
comma.list(1:100)
cat("The following entries were ignored: ", comma.list(c(1,7,10:14)), "\n")

Run the code above in your browser using DataLab