I’m drawing a histogram with the standard hist function with this example dataset:
v= c(0L, 0L, 0L, 1L,1L,1L,2L, 2L, 2L,4L, 4L, 4L)
hist(v, main='example', xlab='example', ylab='example', breaks=5)
The problem that I’m having is that the hist picture looks like this
| ___
|| |
|| |___ ___
|| | | | |
||___|___|___|___|
0 1 2 3 4
So because the 0 starts at the corner, the 0 and 1 bar are combined, and the bar of 2 and 4 looks like it belongs to 1 and 2, 3 and 4. What I want to have is
|
|
| ___ ___ ___ ___
|| | | | | |
||___|___|___|___|___|
0 1 2 3 4
I tried by changing the breaks, but that does not solve the problem of the numbers being at the corner. How can I get the numbers to be centered under the bars?
Maybe you should use
?barplotinstead.