add commas into number for output
Huge thanks to Jonathan Chang for his answer. formatC
looks to be an extremely useful function. This inspired me to read the documentation for it, wherein I found prettyNum
, which turned out to be a pretty elegant solution to a similar problem I was having. Here's a minimum viable example of what I did to add commas to numbers in a data frame named enrollment.summary
.
xtable(prettyNum(enrollment.summary,big.mark=","))
You might want to consider transforming the column using formatC
> formatC(1:10 * 100000, format="d", big.mark=",")
[1] "100,000" "200,000" "300,000" "400,000" "500,000" "600,000"
[7] "700,000" "800,000" "900,000" "1,000,000"