title: ERROR IN GGPLOT IN R-x variable is discrete
body: <p><a href="https://i.stack.imgur.com/xyG3f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xyG3f.png" alt="enter image description here"></a>When executing below R code, getting error like:-   </p>
  
  <p>Code:-</p>
  
  <pre><code>ggplot(train,aes(x = Pclass,fill=factor(Survived)))+
  geom_histogram(width = 0.5)+
  xlab("Pclass")+
  ylab("TotalCount")+
  labs(fill="Survived")
  </code></pre>
  
  <p>Error:-</p>
  
  <blockquote>
    <p>Error: StatBin requires a continuous x variable the x variable is
    discrete. Perhaps you want stat="count"?</p>
  </blockquote>
  
  <p>what could be possible reason ?
  Please help.
  Thanks</p>