Search code examples
rseparator

How to set thousands separator in R?


Anybody knows how to set thousands separator in R?
I would like to get in output sth like that:

123 425 231

or

123.425.231

instead of:

123425231

Thanks.


Solution

  • You can try this:

    x <- 123456789101112 
    formatC(x, format="f", big.mark = ",", digits=0)
    #[1] "123,456,789,101,112"
    

    Of course you can change the entry of "big.mark" as you like, e.g., replace it with a whitespace.