title: How to create a for loop and fill an output matrix in r
body: <p>This is a two part question.</p>
  
  <p>I have a data set that is 2x6 named Price.</p>
  
  <p>I want to create a for loop that will multiply specific rows within Price by (1-h) and -1*(1-h).  The results of this should fill a new matrix that is only 2x3.</p>
  
  <p>The input of Price has values in the first column of rows 1-3, and values in the second column of rows 4-6.  The other values are just zeros.  </p>
  
  <pre><code>h &lt;- .02
  
  &gt; Price
       V1   V2
  1 15.24 0.00
  2 15.24 0.00
  3 15.24 0.00
  4  0.00 8.76
  5  0.00 8.76
  6  0.00 8.76
  </code></pre>
  
  <p>The new matrix should look as the following:</p>
  
  <pre><code>&gt; effective.price
       V1    V2
  1 14.94 -8.58
  2 15.24 -8.76
  3 15.24 -8.76
  </code></pre>
  
  <p>I don't even know where to begin, any help would be greatly appreciated.</p>
  
  <p>Thanks</p>