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
2010-10-01 11:43:42
ThankYou! Looked already for "format" that but another manual from DBI package was shown..
chaostimmy
2010-10-01 11:51:37
+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
2010-10-01 11:43:48
A:
scientific=FALSE seems to be not needed if
options(scipen=999)
is set
chaostimmy
2010-10-01 12:59:45
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
2010-10-01 13:04:33
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
2010-10-01 15:23:44