[R] Customizing breaks for histograms of unequal ranges

From: <e.rapsomaniki_at_mail.cryst.bbk.ac.uk>
Date: Fri 30 Jun 2006 - 22:26:28 EST


I would really appreciate any suggestions on this (rather trivial) problem..

Say I have two vectors:

For a set of common breaks I need to divide the density of v2 over v1. This means that I want to avoid having 0 counts for any v1 breakpoint. But (unsuprisingly) if I define my common breaks as those returned by calling hist for v1:

v1.hist=hist(v1, plot=F)
v2.hist=hist(v2, plot=F, breaks=v1.hist$breaks)

I get an error:
Error in hist.default(v1, plot = F, breaks = v2.hist$breaks) :

        some 'x' not counted; maybe 'breaks' do not span range of 'x'

If I had used the combined vector (c(v1,v2)) to set my breaks I would end up with 0 for some v1 counts. So my question is: is there a way to define breaks that cover the whole range of v1 and v2 while avoiding having 0 for the shortest vector?

Many thanks
Eleni Rapsomaniki
Birkbeck College, UK

R-help@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 Received on Fri Jun 30 22:32:53 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 01 Jul 2006 - 00:17:56 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.