Skip to content
Prev 366228 / 398502 Next

histogram first bar wrong position

Looking at the return value of hist will show you what is happening:
$breaks
 [1] 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0

$counts
 [1] 60 50  0 40  0 30  0 20  0 10
...

The the first bin is [1-1.5], including both endpoints, while the other
bins include only the upper endpoint.  I recommend defining your
own breakpoints, ones don't include possible data points, as in
$breaks
[1] 0.5 1.5 2.5 3.5 4.5 5.5 6.5

$counts
[1] 60 50 40 30 20 10
...

S+ had a 'factor' method for hist() that did this sort of thing, but R does
not.


Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Dec 22, 2016 at 5:17 AM, itpro <itpro1 at yandex.ru> wrote: