If you use the code you will see how the R decided to break up your data:
data(mtcars)
histinfo <- hist(mtcars$mpg)
From the histinfo
you will get the necessary information concerning the breaks.
$breaks
[1] 10 15 20 25 30 35
$counts
[1] 6 12 8 2 4
$density
[1] 0.0375 0.0750 0.0500 0.0125 0.0250
$mids
[1] 12.5 17.5 22.5 27.5 32.5
$xname
[1] "mtcars$mpg"
$equidist
[1] TRUE
attr(,"class")
[1] "histogram"
>
Now you can tweak the code below to make your ggplot histogram, look more like the base one. You would have to change axis labels, scale and colours. theme_bw()
will help you to get some settings in order.
data(mtcars)
require(ggplot2)
qplot(mtcars$mpg,
geom="histogram",
binwidth = 5) +
theme_bw()
and change the binwidth
value to whatever suits you.
