Reputation: 13
This is the line that I used to draw a histogram using the ggplot2
package,
ggplot(ex0116, aes(PerCapitaGDP)) +geom_histogram(fill=NA, color="black") + theme_bw()
When I activate it, it shows a desired histogram and the message that says
'stat_bin()' using 'bins=30'.Pick better value with 'binwidth'
appears.
So I guess that I have a total of 30 bins, but what I want to do is to get the default bin width of this histogram, not the number of bins. I know how to change the bin width, but don't know how to get the default bin width.
What can I do in this situation?
Upvotes: 0
Views: 1011
Reputation: 41
The easiest way for you would be:
diff(range(ex0116$PerCapitaGDP))/30
This is the way ggplot2
calculates the bin width.
Hope it helps!
Upvotes: 1