Re: [R] histogram first bar wrong position

2016-12-23 Thread peter dalgaard
> On 22 Dec 2016, at 18:08 , William Dunlap via R-help > wrote: > > As a practical matter, 'continuous' data must be discretized, so if you > have long vectors of it you will run into this problem. Yep, and it is a bit unfortunate that hist() tries to use "pretty" breakpoints, so that you wil

Re: [R] histogram first bar wrong position

2016-12-23 Thread Martin Maechler
> William Dunlap > on Thu, 22 Dec 2016 09:08:35 -0800 writes: > As a practical matter, 'continuous' data must be discretized, so if you > have long vectors of it you will run into this problem. > Bill Dunlap > TIBCO Software > wdunlap tibco.com Yes, it is true th

Re: [R] histogram first bar wrong position

2016-12-22 Thread Ted Harding
Willam has listed the lid on the essence of the problem, which is that in R the way that breaks (and therefore counts) in a histogram are evaluated is an area of long grass with lurking snakes! To get a glimpse of this, have a look at ?hist and in the seaction "Arguments", look at "breaks", "fre

Re: [R] histogram first bar wrong position

2016-12-22 Thread William Dunlap via R-help
As a practical matter, 'continuous' data must be discretized, so if you have long vectors of it you will run into this problem. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Dec 22, 2016 at 8:19 AM, Martin Maechler wrote: > > itpro > > on Thu, 22 Dec 2016 16:17:28 +0300 wri

Re: [R] histogram first bar wrong position

2016-12-22 Thread William Dunlap via R-help
Looking at the return value of hist will show you what is happening: > x <- rep(1:6,10*(6:1)) > z <- hist(x, freq=TRUE) > z $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 ot

Re: [R] histogram first bar wrong position

2016-12-22 Thread Martin Maechler
> itpro > on Thu, 22 Dec 2016 16:17:28 +0300 writes: > Hi, everyone. > I stumbled upon weird histogram behaviour. > Consider this "dice emulator": > Step 1: Generate uniform random array x of size N. > Step 2: Multiply each item by six and round to next bigger in

[R] histogram first bar wrong position

2016-12-22 Thread itpro
Hi, everyone. I stumbled upon weird histogram behaviour. Consider this "dice emulator": Step 1: Generate uniform random array x of size N. Step 2: Multiply each item by six and round to next bigger integer to get numbers 1 to 6. Step 3: Plot histogram. > x<-runif(N) > y<-ceiling(x*6) > hist(y,