0

Does a function / method already exist to determine the frequency of data greater than some value? Similar to the Excel frequency distribution, I would like to group extreme values into the last bin (e.g., >120 as in image). I have been doing this manually by first using the hist function and then summing the counts for breaks greater than a given value.

Histogram with bins, 0, 10, 20, ..., 120, >120

user1420372
  • 2,077
  • 3
  • 25
  • 42
  • 1
    Please provide a reproducible example http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – alexwhan Jun 17 '13 at 05:27

1 Answers1

7

Here's one option:

d <- rlnorm(1000, 3)
d.cut <- cut(d, c(seq(0, 120, 10), Inf))
hist(as.numeric(d.cut), breaks=0:13, xaxt='n', xlab='', 
     col=1, border=0, main='', cex.axis=0.8, las=1)
axis(1, at=0:13, labels=c(seq(0, 120, 10), '>120'), cex.axis=0.8)
box()

enter image description here

jbaums
  • 27,115
  • 5
  • 79
  • 119