1

I've a very large vector (v) of integers (98754 values) that ranges from 1 to 510, but there aren't all the integers (for example, the value 509 never appears).

> str(v)
 num [1:98754] 1 1 1 1 1 1 1 1 1 1 ...
> summary(v)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   1.00    1.00    1.00   38.76   54.00  510.00 

I would like to do an histogram with 51 bins: the first bin should contain values from 1 to 10, the second from 11 to 20 and so on 'till 510.

It seems very easy to do it with hist(), but I'm not sure using the script posted below is correct

hist(v, breaks=51)

Otherwise, I tried the suggestions posted here Understanding hist() and break intervals in R but the plot returned less than 51 bins due to the absence of some values (i.e. 509 as explained before, for example).

Basically I'm stacked in a real simple trouble, any suggestion?

Franza
  • 45
  • 6

1 Answers1

1

The breaks argument can be a vector with arbitrary cutpoints

hist(runif(1e3,0,500),breaks=seq(0,500,10))
user2974951
  • 9,535
  • 1
  • 17
  • 24