title: Equal frequency and equal width binning in R
body: <p>Given a dataset, I want to partition it into 4 bins using both equal frequency binning and equal width binning as described <a href="http://www.saedsayad.com/unsupervised_binning.htm" rel="nofollow noreferrer">here</a>, But I want to use R language. </p>
  
  <p>Dataset:</p>
  
  <pre><code>0, 4, 12, 16, 16, 18, 24, 26, 28
  </code></pre>
  
  <p>I have tried to write a little code for equal width binning but it just produces a histogram.</p>
  
  <pre><code>bins&lt;-4;
  minimumVal&lt;-min(dataset)
  maximumVal&lt;-max(dataset)
  width=(maximumVal-minimumVal)/bins;
  edges = minimumVal:width:maximumVal;
  hist(dataset, breaks = "Sturges", freq = TRUE, xlim = range(edges))
  </code></pre>
  
  <p>I am new to R.</p>