e.rapsomaniki at mail.cryst.bbk.ac.uk
2006-Jun-30 12:26 UTC
[R] Customizing breaks for histograms of unequal ranges
Hi, I would really appreciate any suggestions on this (rather trivial) problem.. Say I have two vectors: v1=seq(1:10) v2=seq(1:15) 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