title: How to row-wise subtract a vector keeping the means of a data frames (df) columns from df?
body: <p>Sorry for the confusing title ... here is what I want to do with a <em>possible</em> solution:</p>
  
  <pre><code>&gt; df &lt;- data.frame(a=c(1,2,3),b=c(4,5,6))
  &gt; v &lt;- colMeans(df)
  
  &gt; df
    a b
  1 1 4
  2 2 5
  3 3 6
  
  &gt; v
  a b 
  2 5 
  
  &gt; t(t(df)-v)
        a  b
  [1,] -1 -1
  [2,]  0  0
  [3,]  1  1
  </code></pre>
  
  <p>But the data frame will have named columns and rows and be quite large. Which is why I am not comfortable with this solution and would like to know if there is a programmatical one out there which does (of course) not resort to loops and has no need for clumsy double-transpositions (maybe even fits neatly into a single line).</p>