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 --------------------> version_ 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:> 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 SurkoAs 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. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
hist() does not label bins: it is not a barplot. It labels an x axis, from which you can read the boundaries of the bins, in this case [2,3], (3,4], (4,5], (5,6]. That's what the help page says it does, so where is the bug in R? On Fri, 31 Jan 2003 surko@salk.edu wrote:> The command hist(c(2,2,2,4,5,6)) returns a histogram thatlooks incorrect -- 3 in the bin labeled 2 on the left, but 1 each in the bins labeled 3,4,5 on the left. -- 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
__ aldus surko@salk.edu __> 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.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? -- Peter Kleiweg http://www.let.rug.nl/~kleiweg/