0

I am building the histogram in R using ggplot2 package using the below code-

ggplot(cohort, aes(x=ltv))+
 geom_histogram()

It is supposed to result in the histogram returning 30 bins as the default, but it is not doing it. It returns one bar instead of 30 why would that be?

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • 6
    When I do `ggplot(mtcars, aes(x=mpg)) + geom_histogram()`, it has 30 bins. Please provide sample data by editing your question and [pasting](https://stackoverflow.com/editing-help#syntax-highlighting) in the output from `dput(head(cohort$ltv,n=50))` (50 or so, enough to demonstrate). (Refs on reproducible questions: https://stackoverflow.com/questions/5963269, https://stackoverflow.com/help/mcve, and https://stackoverflow.com/tags/r/info.) – r2evans Jul 23 '19 at 19:47
  • Are you sure you've got a numeric vector, not a factor or something else? – camille Jul 23 '19 at 22:21
  • You could also just have a single unique value. But who knows, we are just stabbing in the dark without any data provided, and no response. – Axeman Jul 24 '19 at 03:34

0 Answers0