title: Is it possible to summarize data by columns in a data frame in R?
body: <p>I would like to know if there is a way to &quot;compact&quot; data frames in R.</p>
  <p>I have a change tracker from a document. Currently, my fata frame looks like this:</p>
  <p><a href="https://i.stack.imgur.com/xDVLO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xDVLO.png" alt="enter image description here" /></a></p>
  <p>Here we can see that there is a change per row, which is then separated in different section and if information is added and removed.</p>
  <p>I would like to know if there is any function in R that allows users to &quot;compact&quot; the information in the data frames like so:</p>
  <p><a href="https://i.stack.imgur.com/i1mmF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i1mmF.png" alt="enter image description here" /></a></p>
  <p>Here the information is summarised in each column for each sectio, making the table a little bit more human readable.</p>
  <p>Is this possible?</p>
  <p>Thank you!</p>
  <p>Here you can dinf some data to reproduce this case:</p>
  <pre><code>DOCUMENT&lt;- c(&quot;DOC1&quot;,&quot;DOC1&quot;,&quot;DOC1&quot;,&quot;DOC1&quot;,&quot;DOC1&quot;,&quot;DOC1&quot;)
  DATE&lt;- c(&quot;day&quot;,&quot;day&quot;,&quot;day&quot;,&quot;day&quot;,&quot;day&quot;,&quot;day&quot;)
  SectionA.added&lt;- c(&quot;Change 1&quot;, &quot;Change2&quot;, &quot;change3&quot;, NA, NA, NA)
  SectionA.deleted&lt;- c(NA, NA, NA, &quot;Change 4&quot;, NA,NA)
  SectionB.added&lt;- c(NA, NA, NA, NA, &quot;Change5&quot;, NA)
  SectionB.deleted&lt;- c(NA, NA, NA, NA, NA, NA)
  OTHERS&lt;- c(NA, NA, NA, NA, NA, &quot;Change 6&quot;)
  
  changes_df &lt;- data.frame(DOCUMENT,DATE, SectionA.added, SectionA.deleted, SectionB.added, SectionB.deleted, OTHERS )
  </code></pre>