[R] Mosaicplot with different colors

Jan Sabee jan.sabee at gmail.com
Tue Mar 29 23:35:43 CEST 2005


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)
> 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.
How can I do that? Or are there any others package?
Thanks in advance for any assistance.

Jan Sabee




More information about the R-help mailing list