[R] Customizing breaks for histograms of unequal ranges

e.rapsomaniki at mail.cryst.bbk.ac.uk e.rapsomaniki at mail.cryst.bbk.ac.uk
Fri Jun 30 14:26:28 CEST 2006


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

More information about the R-help mailing list