title: For loop conversion from Stata to R
body: <p>I am trying to learn more about R loops and I want to convert the following Stata loop to R:</p>
  
  <pre><code>generate newvar=0
  
  forvalues i=1/25 {
      replace newvar=1 if PR`i'=="8512" | PR`i'=="8521"  
  }
  </code></pre>
  
  <p>Reading other posts wasn't as clear to me, hence this new post.</p>