[R] Thousand separator in format of axis

2006-09-17 Thread Ruben Roa Ureta
Hi:
How can i make that the numbers in the tick annotations of an axis be
written as, say 20 000 and not 2 (i.e. with the little gap seprating
thousands)?
Thanks
Ruben

__
R-help@stat.math.ethz.ch 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.


Re: [R] Thousand separator in format of axis

2006-09-17 Thread Richard M. Heiberger
 format(1, big.mark= )
[1] 10 000
 format(seq(1,10,1), big.mark= , scientific=FALSE)
 [1]  10 000  20 000  30 000  40 000  50 000  60 000  70 000
 [8]  80 000  90 000 100 000

 plot(seq(1, 10, 1), yaxt=n)
 axis(2, at=seq(1, 10, 1), labels=format(seq(1,10,1),
+   big.mark= , scientific=FALSE))

__
R-help@stat.math.ethz.ch 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.


Re: [R] Thousand separator in format of axis

2006-09-17 Thread Marc Schwartz
On Sun, 2006-09-17 at 17:47 -0400, Ruben Roa Ureta wrote:
 Hi:
 How can i make that the numbers in the tick annotations of an axis be
 written as, say 20 000 and not 2 (i.e. with the little gap seprating
 thousands)?
 Thanks
 Ruben


There are several ways to format numbers:
  ?format
  ?sprintf  
  ?formatC

A quick example:

 y - seq(0, 10, 1)
 
 # Set the y axis so that it does not get drawn
 # See ?par
 plot(1:11, y, yaxt = n, ylab = )

 # Use formatC() and set 'big.mark' to  
 # See ?axis also
 axis(2, at = y, labels = formatC(y, big.mark =  , format = d), 
  las = 2)

 
HTH,

Marc Schwartz

__
R-help@stat.math.ethz.ch 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.