title: R dplyr summarize_each --> "Error: cannot modify grouping variable"
body: <p>I'm trying to use dplyr to group and summarize a dataframe, but keep getting the following error: </p>
  
  <blockquote>
    <p>Error: cannot modify grouping variable</p>
  </blockquote>
  
  <p>Here's the code that generates it:</p>
  
  <pre><code>data_summary &lt;- labeled_dataset %&gt;%
      group_by("Activity") %&gt;%
      summarise_each(funs(mean))
  </code></pre>
  
  <p>Here's the structure of the data frame that I'm applying this to:</p>
  
  <pre><code>&gt; str(labeled_dataset)
  'data.frame':   10299 obs. of  88 variables:
   $ Subject                          : int  1 1 1 1 1 1 1 1 1 1 ...
   $ Activity                         : Factor w/ 6 levels "LAYING","SITTING",..: 3 3 3 3 3 3 3 3 3 3 ...
   $ tBodyAccmeanX                    : num  0.289 0.278 0.28 0.279 0.277 ...
   $ tBodyAccmeanY                    : num  -0.0203 -0.0164 -0.0195 -0.0262 -0.0166 ...
   $ tBodyAccmeanZ                    : num  -0.133 -0.124 -0.113 -0.123 -0.115 ...
   $ tGravityAccmeanX                 : num  0.963 0.967 0.967 0.968 0.968 ...
   $ tGravityAccmeanY                 : num  -0.141 -0.142 -0.142 -0.144 -0.149 ...
   $ tGravityAccmeanZ                 : num  0.1154 0.1094 0.1019 0.0999 0.0945 ...
     ...
  </code></pre>
  
  <p>The only reference I've found to this error is another post that suggests ungrouping first to make sure the data isn't already grouped. I've tried that without success. </p>
  
  <p>Thanks,</p>
  
  <p>Luke</p>