tags:

views:

104

answers:

3

Hey guys, is there a function in R to display large numbers separated with commas? from: 1000000 to: 1,000,000

+5  A: 

See ?format:

> format(1e6, big.mark=",", scientific=FALSE)
[1] "1,000,000" 
>   
Dirk Eddelbuettel
ThankYou! Looked already for "format" that but another manual from DBI package was shown..
chaostimmy
+10  A: 

You can try either format or prettyNum, but both functions return a vector of characters. I'd only use that for printing.

> prettyNum(12345.678,big.mark=",",scientific=F)
[1] "12,345.68"
> format(12345.678,big.mark=",",scientific=F)
[1] "12,345.68"
Joris Meys
A: 

scientific=FALSE seems to be not needed if
options(scipen=999) is set

chaostimmy
That's true. with options(scipen=999), you reach Inf before you go to scientific notation. But that's not exactly the standard setting so to say...
Joris Meys
on a sidenote, you should put these things as a comment. Answers are only used for complete answers to the questions. It will save you unnecessary downvoting.
Joris Meys
okay, now I've learned
chaostimmy