title: Create a matrix with loop in R
body: <p>I trying to create a loop in R, that replace im my matrix the 0 by 1 on in each 2 rows, 
  but I just can create one matrix with number 1. I don´t know how to implement it fast and right!</p>
  
  <p>R code</p>
  
  <pre><code>i&lt;-1
  r&lt;-1
  l&lt;-1
  repeat{
      while(i&lt;3){
          if(l&lt;7) {
              r&lt;-rbind(r,1) 
              l&lt;-l+1
          }else{
              r&lt;-cbind(r,1)
              i&lt;-i+1
              l&lt;-1
          }
      }
  }
  </code></pre>
  
  <p>start example matrix</p>
  
  <pre><code>0   0   0
  0   0   0
  0   0   0
  0   0   0
  0   0   0
  0   0   0
  </code></pre>
  
  <p>final matrix:</p>
  
  <pre><code>1   0   0
  1   0   0
  0   1   0
  0   1   0
  0   0   1
  0   0   1
  </code></pre>