[R] Strange graphical pattern when using hist() function

David Winsemius dwinsemius at comcast.net
Tue Apr 23 20:38:03 CEST 2013


On Apr 23, 2013, at 10:40 AM, Humberto Mohr wrote:

> Running the following lines I got a strange plot from hist function:
> 
> x<-0:30
> hist(x,breaks=31)
> 
> As you can see, the 0 value appears two times in the plot. 
> The Y axis only presents 1 as the highest value when:
> 
> hist(x,breaks=62)
> 
> Nevertheless, it seems to have two bars between 0 and 1.
> 
> Could someone please explain to me why it is happening?

The function is behaving as described in the help page:

"If right = TRUE (default), the histogram cells are intervals of the form (a, b], i.e., they include their right-hand endpoint, but not their left one, with the exception of the first cell when include.lowest is TRUE."

-- 
David Winsemius
Alameda, CA, USA



More information about the R-help mailing list