[R] Mosaicplot with different colors

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Wed Mar 30 00:06:34 CEST 2005


On Tue, 29 Mar 2005, Jan Sabee wrote:

> This dataset below is one sample answer the questioner from our customer.
>
> > testbank <- read.table("testbank.txt", header=T)
> > testbank
>      age married income gender ownhouse class
> 1  20-30      no   high female      yes   1st
> 2  30-40      no   high female      yes   1st
> 3  40-50      no    low female      yes   1st
> 4  50-60      no   high female      yes   1st
> 5  60-70      no   high female      yes   1st
> 6  20-30      no   high female      yes   1st
> 7  20-30      no medium female      yes   1st
> 8  20-30      no    low female      yes   1st
> 9  20-30      no   high   male      yes   1st
> 10 20-30      no   high female      yes   1st
> 11 30-40      no   high female      yes   1st
> 12 40-50      no   high female      yes   1st
> 13 50-60      no medium female      yes   1st
> 14 20-30      no medium female      yes   1st
> 15 20-30      no    low female      yes   1st
> 16 20-30      no   high   male      yes   1st
> > testbank.tab <- table(testbank)
> > library(vcd)
> > mosaicplot(testbank.tab)

You don't see very much in that plot, do you? 16 observations is not too
much for 6-way information.

> > mosaicplot(testbank.tab, shade=T)
>
> I know mosaicplot (package vcd) can handle for this dataset.
> I want to plot that dataset which different colors for age, income and gender.

Do you want to have a color code which codes all three variables at the
same time? I wouldn't have a straightforward solution for that. But if you
want to shade with respect to a single variable, that might be possible.
You can use
  mosaicplot(mytable, col = ...)
and shade with respect to the last margin added.

> How can I do that? Or are there any others package?

We have a much more flexible implementation of mosaicplots (written in
grid) which will (hopefully) soon be released that allows the
specification of arbitrary color patterns in mosaicplots. If you're
interested, contact me offlist and we'll send you a devel-snapshot.
Z

> Thanks in advance for any assistance.
>
> Jan Sabee
>
> ______________________________________________
> R-help at 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
>




More information about the R-help mailing list