title: In R, how can I use group by for multiple column?
body: <p>I have one raw dataset. And I am trying to make my desired output.</p>
  
  <p>The raw dataset is like below:</p>
  
  <pre><code>    gender type neg_sentiment neu_sentiment  pos_sentiment
  1       M  rep          7871          3454          7290
  2       F  rep           841           469           548
  3       M  rep            23            12            26
  4       M  rep           211            73            63
  5       M  rep          2587           868          1251
  6       M  rep          1273           606           594
  7       M  rep           374           150           260
  8       M  rep            30            23           138
  9       M  rep            95            30            23
  10      M  rep            22            22           121
  </code></pre>
  
  <p>Using this, my desired output(with example value of sum) is like below:</p>
  
  <pre><code>gender neg_sentiment    neu_sentiment     pos_sentiment
    M      10000             5000              3000
    F      2000               500              7000
  </code></pre>
  
  <p>What I did is:</p>
  
  <pre><code>df %&gt;% group_by(gender) %&gt;% summarise_all(sum)
  df %&gt;% group_by(type) %&gt;% summarise_all(sum)
  </code></pre>
  
  <p>But it did not work.</p>
  
  <p>Could you help me make the desired output?</p>
  
  <p>Dput is below:</p>
  
  <pre><code>structure(list(gender = structure(c(2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("F", "M"), class = "factor"), type = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("rep", "sen"), class = "factor"), neg_sentiment = c(7871L, 841L, 23L, 211L, 2587L, 1273L, 374L, 30L, 95L, 22L), neu_sentiment = c(3454L, 469L, 12L, 73L, 868L, 606L, 150L, 23L, 30L, 22L), pos_sentiment = c(7290L, 
  548L, 26L, 63L, 1251L, 594L, 260L, 138L, 23L, 121L)), row.names = c(NA, 10L), class = "data.frame")
  </code></pre>