Hello, I am trying to plot a histogram in R using a variable in my dataset. However, the plot appears with 30 bins and some spaces, which I understand as there is no value within this range/bin. Thus, I've tried to change the number of bins to 10 but, still getting this message stat_bin() using bins = 30. Pick better value with binwidth, and the plot does not change at all.
Please advise how should I revise my code to get different bins number? Many thanks!
Below is my code with bins = 10:
# Load tidyverse
library(tidyverse)
# Read diabetes.csv file into a data frame
diabetes <- read_csv("https://raw.githubusercontent.com/malcolmbarrett/au-stats412-612-01-reading_data/master/diabetes.csv")
# Plot ahistogram for the heights variable inside the diabetes data frame
just_height <- data.frame(drop_na(diabetes[, "height"]))
ggplot(just_height, aes(x = height), bins = 10) +
geom_histogram()
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
