title: Subtract number from matrix in R when condition holds
body: <p>I know how to do some transformations to the table I read from file:</p>
  
  <pre><code>data = read.table(file, sep=" ", header=TRUE, stringsAsFactors=F)
  data_transformed=cbind(data[, 1], round(
          data[, seq(from = 3, to = ncol(data), by = 3)] *100 /
          data[, seq(from = 2, to = ncol(data), by = 3)], digits=2))
  </code></pre>
  
  <p>And how to replace "Inf" by "0".</p>
  
  <pre><code>data_transformed[data_transformed==Inf] &lt;- 0
  </code></pre>
  
  <p>Now, I need every number greater than 100 replace by (value-2*(value-100)) so that 130 will be replaced by 70 and 110 will be replaced by 90.</p>
  
  <p>I am using following code, which does not work:</p>
  
  <pre><code>data_transformed[data_transformed&gt;100] &lt;- (data_transformed-2*(data_transformed-100))
  </code></pre>
  
  <p>Any suggestion how to fix it? Thank you very much.</p>
  
  <p>I am getting this error:</p>
  
  <pre><code>Error in rowMeans(data_transformed, na.rm = TRUE) : 'x' must be numeric
  </code></pre>