title: rowMeans function in dplyr
body: <p>I have been trying to run the calculate <code>rowMeans</code> within <code>dplyr</code>'s <code>mutate</code> function, but keep getting errors. Below is an example DATA set and desired RESULT.</p>
  
  <pre><code>DATA = data.frame(SITE = c("A","A","A","A","B","B","B","C","C"), 
                    DATE = c("1","1","2","2","3","3","3","4","4"), 
                    STUFF = c(1, 2, 30, 40, 100, 200, 300, 5000, 6000),
                    STUFF2 = c(2, 4, 60, 80, 200, 400, 600, 10000, 12000))
  
  RESULT = data.frame(SITE = c("A","A","A","A","B","B","B","C","C"), 
                      DATE = c("1","1","2","2","3","3","3","4","4"), 
                      STUFF = c(1, 2, 30, 40, 100, 200, 300, 5000, 6000),
                      STUFF2 = c(2, 4, 60, 80, 200, 400, 600, 10000, 12000),
                      NAYSA = c(1.5, 3, 45, 60, 150, 300, 450, 7500, 9000))
  </code></pre>
  
  <p>The code I have written begins by randomly sampling <code>STUFF</code> and <code>STUFF2</code>. Then I would like to calculate the <code>rowMeans</code> of <code>STUFF</code> and <code>STUFF2</code> and export the result to a new column. I could accomplish this task using <code>tidyr</code>, but would have to redo a larger number of variables. Furthermore I could use the R base package, but prefer to find a solution using the <code>mutate</code> function in <code>dplyr</code>. Thanks in advance.</p>
  
  <pre><code>RESULT = group_by(DATA, SITE, DATE) %&gt;%
    mutate(STUFF=sample(STUFF,replace= TRUE), STUFF2 = sample(STUFF2,replace= TRUE))%&gt;%
    # These approaches return errors 
    mutate(NAYSA = rowMeans(DATA[,-1:-2]))
    mutate(NAYSA = rowMeans(.[,-1:-2])) 
    mutate (NAYSE = rowMeans(.))
  </code></pre>