title: R: How to Plot two columns comparative histogram in single plot?
body: <p>R: How to Plot two columns comparative histogram in single plot?</p>
  
  <pre><code>due_vs_prom &lt;- factor( c(unique(inv$Due_Bin)),levels = c("early","&lt;=5","&lt;=30","&lt;=10","&lt;=50","&gt;50"))
  due_counts &lt;- inv %&gt;% group_by(Due_Bin) %&gt;% summarize(count = n())
  prom_counts &lt;- inv %&gt;% group_by(Prom_Bin) %&gt;% summarize(count = n())
  
  due_vs_prom &lt;- data.frame(due_vs_prom , due_counts , prom_counts )
  
  plot_due_vs_prom &lt;- plot_ly(due_vs_prom, y = ~due_counts , x = ~ (prom_counts), type = 'bar', name = 'Due_Bin') %&gt;%
    add_trace(x = ~due_counts, name = 'Late Bin') %&gt;%
    layout(xaxis = list(title = 'Count'), barmode = 'group')
  
  </code></pre>
  
  <p>DataSet like:</p>
  
  <pre><code>Promise_Bin             Due_Bin
  
  early                   early             
  early                   &gt;50
  early                   &gt;50
  &gt;50                     &gt;50
  &gt;50                     &gt;50
  &lt;=50                    &lt;=50
  early                   early
  early                   early
  &lt;=5                     &lt;50
  &lt;=5                     &lt;=5
  &lt;=30                    &lt;=30
  early                   early
  &lt;=30                    &gt;50
  &lt;=30                    &lt;=30                    
  &lt;=10                    &lt;=10
  
  </code></pre>
  
  <p>Expected plot:
  <a href="https://i.stack.imgur.com/PrCKY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PrCKY.png" alt="enter image description here"></a></p>