Skip to content

hist (PR#2512)

4 messages · surko@salk.edu, Peter Dalgaard, Peter Kleiweg +1 more

#
The command hist(c(2,2,2,4,5,6)) returns a histogram that looks incorrect -- 3 in the bin labeled 2 on the left, but 1 each in the bins labeled 3,4,5 on the left.

Thanks!
Pam Surko

--------------------
_              
platform i386-pc-mingw32
arch     i386           
os       mingw32        
system   i386, mingw32  
status                  
major    1              
minor    6.2            
year     2003           
month    01             
day      10             
language R              


Pam Surko
Visiting Scientist, Ecker Plant Bio Lab
Salk Institute, 10010 N. Torrey Pines Rd. 
La Jolla CA  92037 
858 453-4100  X1796


	[[alternate HTML version deleted]]
#
surko@salk.edu writes:
As documented (notice the include.lowest argument), so not a bug. Also S-PLUS
compatible.

Histogramming of integers has these pitfalls. For an alternative, you
might want to look up truehist() in the MASS package.
#
__ aldus surko@salk.edu __
That looks as it is supposed to look, according to the help
page. However, if I run this example with include.lowest=FALSE,
I get an error:

    > hist(c(2,2,2,4,5,6),include.lowest=FALSE)
    Error in hist.default(c(2, 2, 2, 4, 5, 6), include.lowest = FALSE) :
        some `x' not counted; maybe `breaks' do not span range of `x'

Similar if I add right=FALSE:

    > hist(c(2,2,2,4,5,6),include.lowest=FALSE,right=FALSE)
    Error in hist.default(c(2, 2, 2, 4, 5, 6), include.lowest = FALSE, right = FALSE) :
        some `x' not counted; maybe `breaks' do not span range of `x'


Is this supposed to happen?
#
On Fri, 31 Jan 2003, Peter Kleiweg wrote:

            
Yes.