1

A very quick question that has more to do with my ability to understand the R help files:

x <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
h1 <- hist(x, breaks = seq(0,20,by=1), include.lowest = FALSE)
Error in hist.default(x, breaks = seq(0, 20, by = 1), include.lowest = FALSE  
  some 'x' not counted; maybe 'breaks' do not span range of 'x'
h2 <- hist(x, breaks = seq(0,20,by=1), include.lowest = TRUE)

The first histogram produces an error, the second one doesn't.

From the help files: breaks: "a vector giving the breakpoints between histogram cells"

include.lowest: logical; if TRUE, an x[i] equal to the breaks value will be included in the first (or last, for right = FALSE) bar. This will be ignored (with a warning) unless breaks is a vector.

Am I correct in understanding that include.lowest refers to include.lowest.break and NOT include.lowest.datapoint? Just checking. Thanks.

1 Answer 1

8

Intervals are left-open, right-closed by default. That is, they include the break point at the right end of each interval. The lowest endpoint is not included by default. To include lowest endpoint set include.lowest=TRUE. That is the reason why first hist fails and second one passes. Hope this answers your point.

You are correct in understanding that include.lowest refers to include.lowest.break and NOT include.lowest.datapoint

1
  • 1
    Thanks rags, I think it's useful to have this in stackoverflow for the record!
    – PatrickT
    Commented Nov 13, 2013 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.