title: Calculating standard deviation across rows
body: <p>Say I have the following data:</p>
  
  <pre><code>colA &lt;- c("SampA", "SampB", "SampC")
  colB &lt;- c(21, 20, 30)
  colC &lt;- c(15, 14, 12)
  colD &lt;- c(10, 22, 18)
  df &lt;- data.frame(colA, colB, colC, colD)
  df
  #    colA colB colC colD
  # 1 SampA   21   15   10
  # 2 SampB   20   14   22
  # 3 SampC   30   12   18
  </code></pre>
  
  <p>I want to get the row means and standard deviations for the values in columns B-D.</p>
  
  <p>I can calculate the rowMeans as follows:</p>
  
  <pre><code>library(dplyr)
  df %&gt;% select(., matches("colB|colC|colD")) %&gt;% mutate(rmeans = rowMeans(.))
  #   colB colC colD   rmeans
  # 1   21   15   10 15.33333
  # 2   20   14   22 18.66667
  # 3   30   12   18 20.00000
  </code></pre>
  
  <p>But when I try to calculate the standard deviation using <code>sd()</code>, it throws up an error.</p>
  
  <pre><code>df %&gt;% select(., matches("colB|colC|colD")) %&gt;% mutate(rsds = sapply(., sd(.)))
  Error in is.data.frame(x) : 
    (list) object cannot be coerced to type 'double'
  </code></pre>
  
  <p>So my question is: how do I calculate the standard deviations here?</p>
  
  <p>Edit: I tried <code>sapply()</code> with <code>sd()</code> having read the first answer <a href="https://stackoverflow.com/questions/24058054/standard-deviation-on-dataframe-does-not-work">here</a>.</p>
  
  <p>Additional edit: not necessarily looking for a 'tidy' solution (base R also works just fine).</p>