2 variables in a for loop in R
<p>I have two vectors that I would like to reference in a for loop, but each is of different lengths.</p>

<pre><code>n=1:50
m=letters[1:14]
</code></pre>

<p>I tried a single loop to read it</p>

<pre><code>for (i in c(11:22,24,25)){
    cat (paste(n[i],m[i],sep='\t'),sep='\n')
}
</code></pre>

<p>and ended up with:</p>

<pre><code>11  k
12  l
13  m
14  n
15  NA
16  NA
17  NA
18  NA
19  NA
20  NA
21  NA
22  NA
24  NA
25  NA
</code></pre>

<p>but I would like to obtain:</p>

<pre><code>11  a
12  b
13  c
...
25  n
</code></pre>

<p>is there a way to have a double variable declaration?</p>

<pre><code>for (i in c(11:22,24,25) and j in 1:14){
    cat (paste(n[i],m[j],sep='\t'),sep='\n')
}
</code></pre>

<p>or something similar to get the result I want?</p>