title: How to change a value to zero, using a loop?
body: <p>The below loop is used to prepare data before I perform survival analyses. <code>Vector_B</code> should be turned to '0' based on the maximum value (= days) in <code>Vector_A</code>. In this example I want the maximum value to be '10'. I already know how to use the ifelse-function for this, but I really want to know how to implement loops instead (in this case a for loop).</p>
  <p>Could you help me out with the script below? I want <code>Vector_B</code> to change to ''0, 0, 1, 0, 0, 0'') because at every <code>Vector_A</code> higher than 10, <code>Vector_B</code> should be '0'.</p>
  <p>Code:</p>
  <pre><code>Vector_A &lt;- c(7, 17, 5, 12, 7, 13) 
  Vector_B &lt;- c(0, 1, 1, 0, 0, 1) 
  for (i in Vector_A) if (i &gt; 10) {(Vector_B &lt;- 0)}
  </code></pre>
  <p>Outcome:</p>
  <blockquote>
  <p>Vector_A: 7 17  5 12  7 13</p>
  </blockquote>
  <blockquote>
  <p>Vector_B: 0</p>
  </blockquote>