Re: [R] format numbers using 1000 separator

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Sat, 05 Apr 2008 00:00:03 +0200

tom soyer wrote:
> Hi,
>
> Does anyone know how one could format numbers using 1000 separator in R? For
> example, format 1000 as 1,000 and 100000 as 100,000, etc.
>
> Thanks,
You're at the mercy of the system sprintf, but on Fedora, this works:

 > Sys.setlocale("LC_NUMERIC","da_DK.UTF-8") [1] "da_DK.UTF-8"
Warning message:
In Sys.setlocale("LC_NUMERIC", "da_DK.UTF-8") :   setting 'LC_NUMERIC' may cause R to function strangely  > sprintf("%'f",pi*1e7)
[1] "31.415.926,535898"
 > Sys.setlocale("LC_NUMERIC","C")
[1] "C"
Warning message:
In Sys.setlocale("LC_NUMERIC", "C") :
  setting 'LC_NUMERIC' may cause R to function strangely

Be aware that those warnings are there for a reason....

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)              FAX: (+45) 35327907

______________________________________________
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.
Received on Fri 04 Apr 2008 - 22:04:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 05 Apr 2008 - 00:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive