title: Tidyverse: Converting numerical data into categorical data for plotting with uneven bin width
body: <p>Using the tidyverse, I'm looking to discretize numerical data with the goal of using a bar chart to plot the different numerical ranges as if the data were categorical, by manually declaring where the cuts occur, such as with age groups or income ranges. I wish to have intervals of unequal width. </p>
  
  <p>So far, I've tried the base R approach, using <code>cut()</code> and setting the bins with <code>breaks = c()</code>. I notice, however, that there exist a set of functions <code>cut_interval</code>, <code>cut_width</code>, and <code>cut_number</code> in the <code>ggplot2</code> package. I figure that there's a way to manually set the interval cuts using these functions, because the <code>breaks</code> argument exists for the interval and number variant.</p>
  
  <pre class="lang-r prettyprint-override"><code>library(tidyverse)
  
  mtcars &lt;- as_tibble(mtcars)
  
  mtcars %&gt;% 
    count(cut_interval(mpg, n = 4))
  #&gt; # A tibble: 4 x 2
  #&gt;   `cut_interval(mpg, n = 4)`     n
  #&gt;   &lt;fct&gt;                      &lt;int&gt;
  #&gt; 1 [10.4,16.3]                   10
  #&gt; 2 (16.3,22.1]                   13
  #&gt; 3 (22.1,28]                      5
  #&gt; 4 (28,33.9]                      4
  
  mtcars %&gt;% 
    count(cut_interval(mpg, n = 4, breaks = c(10, 18, 23, 28, 35)))
  #&gt; Error: Evaluation error: lengths of 'breaks' and 'labels' differ.
  </code></pre>
  
  <p><sup>Created on 2019-06-03 by the <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex package</a> (v0.2.1)</sup></p>
  
  <p>The above is close to what I want, but it sets the breaks based on the number of intervals.</p>
  
  <p>In the above example, I would like my groups to be precisely as follows:</p>
  
  <p>10-18, 19-23, 24-28, 29-35.</p>
  
  <p>Is this possible using the <code>breaks</code> argument? Thank you.</p>