title: For loop to iterate through dplyr pipe
body: <p>I'm trying to get the total number of entries of each row in a dataframe in order to compress on these fields later.</p>
  <p>However the dataframe has over 60 rows and writing the below 60 times is extremely inefficient</p>
  <pre><code>df %&gt;%
      group_by(colname) %&gt;%
      count() %&gt;%
      arrange(desc(n))
  </code></pre>
  <p>Is there a way I can write a for loop to loop through all the names in the dataframe and produce the pipe function result for each? I tried</p>
  <pre><code>for (i in colnames(df)) {
  
  df %&gt;%
      group_by(colname) %&gt;%
      count() %&gt;%
      arrange(desc(n))
  
  }
  </code></pre>
  <p>But I'm getting an 'i is unknown' error. Any help would be appreciated thanks.</p>