title: how to built a new data with summarize and cut command for each age group
body: <p>I want to build new data (age_summary) with a total number of people by age group. I would like to use &quot;cut&quot; and My codes are:</p>
  <pre><code>set.seed(12345)
  
  #create a numeric variable Age       
  AGE &lt;- sample(0:110, 100, replace = TRUE)
  
  # Creat Data fame
  Sample.data &lt;-data.frame(AGE)
  
  age_summary &lt;- Sample.data %&gt;%  summarize(group_by(Sample.data,
                                                     cut(
                                                       AGE,
                                                       breaks=c(0,0.001, 0.083, 2, 13, 65,1000),
                                                       right=TRUE,
                                                       labels = c(&quot;Foetus(0 yr)&quot;,&quot;Neonate (0.001 - 0.082 yr)&quot;,&quot;Infant(0.083-1.999 yrs)&quot;,&quot;Child(2-12.999 yrs)&quot;, &quot;Adolescent(13-17.999 yrs)&quot;,&quot;Adult(18-64.999 yrs.)&quot;,&quot;Elderly(65-199 yrs)&quot;)
    ),&quot;Total people&quot; = n())
  )
  
  </code></pre>
  <p>However my codes do not work. I am not sure what went wrong. Any suggestion on how to solve this?</p>
  <p>Add:
  I was able to get results that look like this:</p>
  <p><a href="https://i.stack.imgur.com/70Puh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/70Puh.png" alt="enter image description here" /></a></p>
  <p>is it possible for me to achieve something looks like this:
  <a href="https://i.stack.imgur.com/Qqf3r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qqf3r.png" alt="enter image description here" /></a></p>
  <p>Here is what I get with adorn_totals(.) on a new data set. the total people looks OK, but the ave-age looks strange.</p>
  <p><a href="https://i.stack.imgur.com/OpGFX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OpGFX.png" alt="enter image description here" /></a></p>
  <p>Any idea?</p>