Perhaps you could shade the bars as appropriate?

I'm not going to use your data because it's not an easily paste-able but how
about this:

x = rnorm(100)
y = sample(c("A","B"),100,replace=T,prob=c(0.7,0.3))

d = data.frame(level = x, status = y)
n = 10 # Number of bins
breaks = quantile(d$level, (0:n)/n)
#breaks = with(d,hist(level,breaks=n,plot=F)$breaks)
breaksAssign = findInterval(d$level,breaks)

percentB = unique(ave(d$status=="B",breaksAssign)[order(breaksAssign)])
percentB = gray(percentB/max(percentB)) # Many other color functions
available as well.

with(d, hist(level, breaks = breaks, col = percentB))

If you want to use hist()'s smart choice of bins (which I'd recommend), you
can call this hist command once with plot=F and get the breaks from there.
I.e., breaks = with(d,hist(level,breaks=n,plot=F)$breaks)

There's probably a smarter way to do all this, but this does seem to work...

Hope this helps,

Michael Weylandt

On Wed, Aug 10, 2011 at 1:16 PM, lt2 <lt2@bcm.edu> wrote:

> HI everyone,
> I'm plotting a histogram in R and within that histogram i need to
> demonstrate the percentage of another variable (Percentage of MutStatus)
> within the bins plotted inthe histogram....I don't know how to do that!
>
> Data:Validation_Status  Mutation_Status TvarRatio
> Wildtype        None    0.08
> Wildtype        None    0.08
> Wildtype        None    0.08
> Wildtype        None    0.08
> Wildtype        None    0.080139373
> Wildtype        None    0.080152672
> Wildtype        None    0.080213904
> Wildtype        None    0.080357143
> Wildtype        None    0.080357143
> Wildtype        None    0.080357143
> Wildtype        None    0.08045977
> Wildtype        None    0.1
> Wildtype        LOH     0.1
> Wildtype        None    0.1
> Wildtype        None    0.1
> Wildtype        None    0.1
> Wildtype        None    0.1
> Wildtype        None    0.1
> Wildtype        Somtatic        0.1
> Wildtype        None    0.100558659
> Wildtype        None    0.100591716
> Wildtype        None    0.101010101
> Wildtype        None    0.101123596
> Wildtype        Gline   0.101333333
> Wildtype        None    0.101369863
> Wildtype        None    0.101449275
> Wildtype        None    0.101522843
> Wildtype        None    0.101604278
> Wildtype        None    0.102040816
> Wildtype        Gline   0.102040816
> Wildtype        None    0.102362205
> Wildtype        None    0.102459016
> Wildtype        None    0.102564103
> Wildtype        None    0.102702703
> Wildtype        None    0.102739726
> Wildtype        None    0.102803738
> Valid   Somatic 0.102941176
> Wildtype        None    0.102941176
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Histograms-in-R-tp3733644p3733644.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

