- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to deal with warning message `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. in R while creating a histogram?
The default value for bins is 30 but if we don’t pass that in geom_histogram then the warning message is shown by R in most of the cases. To avoid that, we can simply put bins=30 inside the geom_histogram() function. This will stop showing the warning message.
Consider the below data frame −
x<-rnorm(50000,5,1) df<-data.frame(x)
Loading ggplot2 package and creating histogram of x −
Example
library(ggplot2) ggplot(df,aes(x))+geom_histogram() `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Output
Creating the histogram by specifying the bins −
Example
ggplot(df,aes(x))+geom_histogram(bins=30)
Output
Advertisements