title: Subtract column-specific value for a particular row from all values in data frame, in R
body: <p>I have a data object <em>signal</em> in R with 40,000+ rows (named variables) of numeric values and 200+ columns (samples). For every row of each column, I want to subtract the value for the row named <em>background</em> for that column.</p>
  
  <p>The code below can be used to create an example <em>signal</em> object in R. With the example, for column A, the <em>background</em> value of 4 is to be subtracted from the values of <em>channelNo1</em> to <em>3</em>. Similarly, for column B, the value of 6 is to be subtracted. And so on. What is the simplest way to achieve this in R? </p>
  
  <pre><code>text &lt;- textConnection('
               A   B   C
  channelNo1  12  22  32
  channelNo2  13  21  33
  channelNo3  12  21  30
  background   4   6   8
  ')
  signal &lt;- read.table(text, header = TRUE)
  close(text)
  
  typeof(signal)
  # returns 'list'
  
  class(signal)
  # returns 'data.frame'
  </code></pre>