[R] sort argument in mosaicplot

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Mar 25 12:31:53 CEST 2007


On Sun, 25 Mar 2007, Jean lobry wrote:

>> x <- matrix(1:4,2,2)
>> mosaicplot(x)
>> # This one is OK
>> mosaicplot(x, sort = 1:length(dim(x)) )

please, seq_len(dim(x)) is designed for this task.

>> # Not OK, I have the following error message:
>> Erreur dans mosaicplot.default(x, sort = 1:length(dim(x))) :
>>         objet "label" non trouv?
>
> More info on this:
>
> i) I was told by a colleague that it was working under the
> (obsolete) R 2.4.0. I have checked this with our RWeb sever which
> is still under R 2.4.0 and it is true that
> mosaicplot(x, sort = 1:length(dim(x)) ) works.
>
> ii) I have tried the same code after sourcing the file at
> https://svn.r-project.org/R/trunk/src/library/graphics/R/mosaicplot.R
> and I have the same error message saying that the object
> "label" was not found.
>
> So, is it a fortune(2) issue or something I have missed in
> the sort argument of mosaicplot() ? I have searched for the
> word "mosaicplot" in the "2.4 SERIES NEWS" and found only one
> occurrence in the changes in R version 2.2.0 saying
> "The default mosaicplot() method by default draws grey boxes"
> that does not seem to be related to the sort argument.
> I have also searched for the word "sort", but none seems to
> be related to the sort agument of mosaicplot().

I don't know why it is not in NEWS, but the function was altered at

r39655 | hornik | 2006-10-17 21:12:53 +0100 (Tue, 17 Oct 2006) | 1 line
Bug fixes by J. Emerson.

and that change has caused your problem.  I will commit a fix to R-devel 
shortly.

> BTW, a completely unrelated question: is it possible to
> turn on/turn off temporarilly (i.e. without quitting
> the R session) the locale settings so as
> to get error and warning messages reported in english?

See the 'R Installation and Administration Manual' chapter 7:

The preferred language for messages is by default taken from the locale. 
This can be overridden first by the setting of the environment variable 
LANGUAGE and then by the environment variables LC_ALL, LC_MESSAGES and 
LANG. (The last three are normally used to set the locale and so should 
not be needed, but the first is only used to select the language for 
messages.) The code tries hard to map locales to languages, but on some 
systems (notably Windows) the locale names needed for the environment 
variable LC_ALL do not all correspond to XPG language names and so 
LANGUAGE may need to be set. (One example is `LC_ALL=es' on Windows which 
sets the locale to Estonian and the language to Spanish.)

It is usually possible (not Windows) to change the language once R is 
running via Sys.setlocale("LC_MESSAGES", "new_locale"), but not by setting 
environment variables such as LANGUAGE.

E.g. (on Linux)

> x <- matrix(1:4,2,2)
> mosaicplot(x, sort = 1:length(dim(x)) )
Error in mosaicplot.default(x, sort = 1:length(dim(x))) :
         object "label" not found
> Sys.setlocale("LC_MESSAGES", "fr_FR")
[1] "fr_FR"
> mosaicplot(x, sort = 1:length(dim(x)) )
Erreur dans mosaicplot.default(x, sort = 1:length(dim(x))) :
         objet "label" non trouvé

[Unfortunately Windows does not support this aspect of locales.]

-- 
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