Full_Name: Reinhold Koch Version: 1.6.1 OS: redhat 8.0 Submission from: (NULL) (131.152.84.111) I came across rather weird behavior of the breaks in hist: hist(1:3) gives the expected result, besides an unnecessary gap between 2nd and 3rd column hist(1:4) always merges up the first two columns, also if I resort to hist.default(1:4,breaks=1:4). hist.default(1:4, include.lowest=F) gives an error: Error in hist.default(1:4, include.lowest = F) : some `x' not counted; maybe `breaks' do not span range of `x'
I am baffled as to why you think there is a bug in R here! On Wed, 8 Jan 2003 reinhold.koch@unibas.ch wrote:> Full_Name: Reinhold Koch > Version: 1.6.1 > OS: redhat 8.0 > Submission from: (NULL) (131.152.84.111) > > > I came across rather weird behavior of the breaks in hist: > > hist(1:3) > > gives the expected result, besides an unnecessary gap between 2nd and 3rd > columnIt gives the expected result, period. There is no gap, but there is a bin with count zero.> hist(1:4) > > always merges up the first two columns,Why is that wierd? You requested three bins and that's what you got. (If you didn't know you had done that, please read the help page.)> also if I resort to > hist.default(1:4,breaks=1:4). hist.default(1:4, include.lowest=F) gives an > error: > > Error in hist.default(1:4, include.lowest = F) : > some `x' not counted; maybe `breaks' do not span range of `x'Why do you even mention that? It's correct! The breaks chosen are to cover a prettified range of x. You explicitly asked for left-open intervals, so you got (1,2], (2,3], (3,4] and those do not cover the data. Perhaps as idiot-proofing, include.lowest should not be allowed unless `breaks' is a sequence of breakpoints. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
I am baffled as to why you think there is a bug in R here! On Wed, 8 Jan 2003 reinhold.koch@unibas.ch wrote:> Full_Name: Reinhold Koch > Version: 1.6.1 > OS: redhat 8.0 > Submission from: (NULL) (131.152.84.111) > > > I came across rather weird behavior of the breaks in hist: > > hist(1:3) > > gives the expected result, besides an unnecessary gap between 2nd and 3rd > columnIt gives the expected result, period. There is no gap, but there is a bin with count zero.> hist(1:4) > > always merges up the first two columns,Why is that wierd? You requested three bins and that's what you got. (If you didn't know you had done that, please read the help page.)> also if I resort to > hist.default(1:4,breaks=1:4). hist.default(1:4, include.lowest=F) gives an > error: > > Error in hist.default(1:4, include.lowest = F) : > some `x' not counted; maybe `breaks' do not span range of `x'Why do you even mention that? It's correct! The breaks chosen are to cover a prettified range of x. You explicitly asked for left-open intervals, so you got (1,2], (2,3], (3,4] and those do not cover the data. Perhaps as idiot-proofing, include.lowest should not be allowed unless `breaks' is a sequence of breakpoints. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Thanks for the details of this feature, I wanted all values been treated equally. I now achieved this through hist(1:4, br=0:4,include.lowest=F) quote:> > hist(1:4) > > > > always merges up the first two columns, > > Why is that wierd? You requested three bins and that's what you got. > (If you didn't know you had done that, please read the help page.)In the help pages I could not find this; the default bin number algorithm nclass.Sturges gives for 1:3 3 bins as a result, but hist(1:3) draws 4.
On Wed, 8 Jan 2003, Reinhold Koch wrote:> Thanks for the details of this feature, > > I wanted all values been treated equally. I now achieved this through > > hist(1:4, br=0:4,include.lowest=F) > > quote: > > > hist(1:4) > > > > > > always merges up the first two columns, > > > > Why is that wierd? You requested three bins and that's what you got. > > (If you didn't know you had done that, please read the help page.) > > In the help pages I could not find this; the default bin number > algorithm nclass.Sturges gives for 1:3 3 bins as a result, but hist(1:3) > draws 4.It says In the last three cases the number is a suggestion only. so what about that sentence do you fail to comprehend? -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595