title: Pairwise loop through multiple vectors in R
body: <h1><strong>What do I have in R?</strong></h1>
  
  <p>The following vectors:</p>
  
  <pre><code>N &lt;- c('a','b')
  M &lt;- c('x','y')
  </code></pre>
  
  <h1><strong>The goal</strong>.</h1>
  
  <p>While keeping the vectors intact (I do not wish to combine them into a matrix), I would like to call the elements of the vectors in the following pairwise fashion:</p>
  
  <pre><code>"a" "x" "b" "y"
  </code></pre>
  
  <h1><strong>The code so far</strong>.</h1>
  
  <p>I've tried to use a <code>for</code> loop, but in the way it is written below, it is read as a nested for loop: </p>
  
  <pre><code>for (i in M) for (j in N)  { 
   print(i)
   print(j)
  }
  </code></pre>
  
  <p>Which results in:</p>
  
  <pre><code>"a" "x" "a" "y" "b" "x" "b" "y"
  </code></pre>
  
  <h1><strong>What I've searched for.</strong></h1>
  
  <p>Using search terms as <em>multiple indices</em>, <em>for loops</em>, and <em>double loops</em>, I was only able to find information on nested loops. The use of flow commands did not help me in my quest.</p>
  
  <h1><strong>The real goal.</strong></h1>
  
  <p>I would like to add one line of text into an image. The textual tags are stored in a single vector and the images are as well. The code I have so far works, except for calling the elements of the vectors in the pairwise fashion explained above. There are plenty of pictures and life's too short to do it all by hand.</p>
  
  <p>Any help would be greatly appreciated!</p>
  
  <p>Stijn</p>