Convert a number to a string, with commas inserted at every 3rd digit.

commas(numbers)

Arguments

numbers

Vector of non-negative numbers (will be rounded to integers)

Value

Character string with numbers written like "5,771,009".

Examples

commas(c(2300, 9000, 21456, 987654890, 1256787, 345765, 1432))
#> [1] "2,300" "9,000" "21,456" "987,654,890" "1,256,787" #> [6] "345,765" "1,432"
#