[R] Multiple groups barplot

michele caseposta mic.cipi at gmail.com
Wed Nov 14 01:04:24 CET 2012


Hi everyone,
I have a certain number of samples and I want to visualize the groups those samples belong to.
For example, suppose to have three variables, age, sex, and smoker/nonsmoker, and three samples, S1, S2, S3.
S1 is 35, male, nonsmoker
S2 is 24, female, nonsmoker
S3 is 24, female, smoker

at the end I have the following data frame:

		S1	S2	S3
age		35	24	30
sex		M	F	F
smk		N	N	S

What I would like is to see this represented in a matrix with colors representing the group the specific sample belongs to. In the example, Age would have three levels, sex and smoker/nonsmoker will have two.

An example of what I would like to obtain is from the attached image (from The Cancer Genome Browser at UCSC)
You can see the class of each sample represented by the color.
Clearly here there are useless variables, like sample name, but the example gives an idea of what I would like to get.

So far I was able to achieve a pseudo-result with colorbar.plot, but I find it hard to get the labels in the correct position, as it seems like I cannot find a way to automatically put them near each class bar

Any suggestions other than colorbar.plot?





More information about the R-help mailing list