title: Plot histogram by first sorting data and then dividing x values into bins in R
body: <p>I have a dataset in a given format:</p>
  
  <pre><code>USER.ID avgfrequency
  1   3   3.7821782
  2   7   14.7500000
  3   9   13.4761905
  4   13  5.1967213
  5   16  6.7812500
  6   26  41.7500000
  7   49  13.6666667
  8   50  7.0000000
  9   51  1.0000000
  10  52  17.7500000
  11  69  4.5000000
  12  75  9.9500000
  13  91  84.2000000
  14  98  8.0185185
  15  138 14.2000000
  16  139 34.7500000
  17  149 7.6666667
  18  155 35.3333333
  19  167 24.0000000
  20  170 7.3529412
  21  171 4.4210526
  22  175 6.5781250
  23  176 19.2857143
  24  177 10.4864865
  25  178 28.0000000
  26  180 4.8461538
  27  183 25.5000000
  28  184 13.0000000
  29  210 32.0000000
  30  215 13.4615385
  31  220 11.3611111
  32  223 26.2500000
  </code></pre>
  
  <p>I want to first sort the dataset by <code>avgfrequency</code> and then I want to plot count of <code>USER.ID's</code> that fall under different bin categories.</p>
  
  <p>I want to divide <code>avgfrequency</code> into different bin categories of width 10.</p>
  
  <p>I am trying to sort data using:</p>
  
  <pre><code>user_avgfrequency &lt;- user_avgfrequency[order(user_avgfrequency[,1]), ]
  </code></pre>
  
  <p>but getting an error.</p>