title: Applying a function row-wise for a dataset
body: <p>hope am able to explain clearly what I would like to do.</p>
  
  <p>I have a matrix </p>
  
  <pre><code>  Z&lt;-matrix(sample(1:40),ncol=4)
  
   colnames(Z)&lt;-c("value","A","B","C")
  
   I would like to apply the following formula to each row in the dataset.
  
  
    Process = value - rowmean (A,B,C)
             ------------------------------------
             row-wise Standard deviation (A,B,C)         
  </code></pre>
  
  <p>I thought of something like calculating everything separately like</p>
  
  <p>Subsettting the data first</p>
  
  <pre><code>   onlyABC&lt;-Z[,1:3]
  </code></pre>
  
  <p>Then apply the rowMeans to each row                 </p>
  
  <pre><code>     means&lt;-apply(onlyABC,1,rowMeans)
  </code></pre>
  
  <p>And similarly compute standard deviation separately using</p>
  
  <pre><code>    deviate&lt;-apply(onlyABC,1,SD)
  </code></pre>
  
  <p>And then I do not know now how to subtract the value column in matrix 'z' from 'means' and then divide by 'deviate'.</p>
  
  <p>Is there a simpler approach to do this?</p>
  
  <p>As an example applying the formula to the first row will give:</p>
  
  <pre><code> row1  32-(19+35+4/3)
         --------------
          SD(19+35+4)
  </code></pre>
  
  <p>Similarly apply the formula to other rows as well and get a vector of size 10 in the end.</p>