[R] Thousands Separator

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Apr 19 09:14:10 CEST 2006


On Wed, 19 Apr 2006, Uwe Ligges wrote:

> David Feldman wrote:
>> I am a new R user, and am struggling with how to add a comma to the
>> tick mark labels in a bwplot or a boxplot.
>>
>> I think the default values of the labels are fine, I just want them
>> to appear with commas.
>>
>> If I use the function boxplot, I can then use
>>    axis(2,labels=format(axTicks(2),big.mark=","))
>> but that just overlays them on the existing labels which I don't know
>> how to turn off.
>
>
> Specify in your plot function: yaxt="n" (see ?par)
>
>
>> This method does not appear to work at all with bwplot, but I am not
>> sure why.
>
> Because it is not a base graphics function but a lattice graphics.

You can use options(OutDec) in both cases:

op <- options(OutDec=",")
z <- 0.01* rt(100, df=3); g <- factor(rep(LETTERS[1:2], each=50))
boxplot(z ~ g)
library(lattice)
bwplot(z ~ g)
options(op)


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list