[R] Combining two histograms

michael watson (IAH-C) michael.watson at bbsrc.ac.uk
Wed Feb 2 14:56:18 CET 2005


Sean
If you want two bars for each bin then that sounds more like barplot() could be used.  I know you can tightly control the distance between bars and the width of the bars, and so with a little coding you could probably use that.
 
Mick

	-----Original Message----- 
	From: r-help-bounces at stat.math.ethz.ch on behalf of Sean Davis 
	Sent: Wed 2/2/2005 1:42 PM 
	To: r-help 
	Cc: 
	Subject: [R] Combining two histograms
	
	

	I have data like:
	
	a <- rnorm(20000)
	b <- rep(FALSE,20000)
	b[sample(1:20000,15000)] <- TRUE
	
	Using Lattice graphics, I can produce two side-by-side histograms quite
	easily by:
	
	histogram(a | b)
	
	However, I would like to produce a "single" histogram with two bars
	within each bin, one for each group, as the groups are in reality very
	slightly different from each other.  The difference isn't evident
	unless one "overlays" the two histograms in some manner.
	
	Thanks,
	Sean
	
	______________________________________________
	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