[R] Newbie: Formatting numbers with commas

Henrik Bengtsson hb at stat.berkeley.edu
Tue Sep 23 06:56:29 CEST 2008


x <- c(123023,143494035);
> format(x, big.mark=",");
[1] "    123,023" "143,494,035"
> format(x, big.mark=",", trim=TRUE);
[1] "123,023"     "143,494,035"

See also ?prettyNum (and formatC).

/Henrik

On Mon, Sep 22, 2008 at 9:23 PM, Matthew Pettis
<matthew.pettis at gmail.com> wrote:
> Hi,
>
> Search through the R archives, and couldn't find my answer... how do
> you format numbers with commas (standard American, one every three
> digits)?
>
> Thanks,
> Matt
>
> --
> It is from the wellspring of our despair and the places that we are
> broken that we come to repair the world.
> -- Murray Waas
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list