R: for loop output
<p>I have two data sets</p>

<pre><code>    data1 &lt;- data.frame(c(0.0000, 0.5949, 0.8190, 1.0350, 
                          0.4960, 0.4000, 0.5000, 
                          0.3000, 0.4560, 0.6338, 1.2110 ),
                         c(0.0000, 0.8445,0.8900,1.1120,0.6780,
                           0.3000,0.5660,0.6000,0.8320,0.5987,1.1740 ))
</code></pre>

<p>and </p>

<pre><code>vector1 &lt;- list(rep(c(10,5,2), 5), rep(c(20,10,5), 5))
</code></pre>

<p>(<code>vector1</code> is a silly example but it keeps the structure of my real list)</p>

<pre><code>    n2 &lt;- 10
    idealized.ranks2 &lt;- c(0:10)
    sorted.z &lt;- NULL
    fonction &lt;- list()
    n.2.bis &lt;- NULL
    n.2.simu.bis &lt;- NULL
    precip.back2 &lt;- rep(list(as.vector(NULL)), 4)

for(z in 1:dim(data1)[2]){
  sorted.z[[z]] &lt;- sort(data1[,z])
  fonction[[z]] &lt;- approxfun(idealized.ranks2, sorted.z[[z]])

  for(x in 1:length(vector1)){
    n.2.bis[[x]] &lt;- pnorm(vector1[[x]])
    n.2.simu.bis[[x]] &lt;- n.2.bis[[x]]*(n2+1)

    precip.back2[[x]] &lt;- fonction[[z]](n.2.simu.bis[[x]])
    print(z)
  }
}
[1] 1
[1] 1
[1] 2
[1] 2
</code></pre>

<p>The output gives me the results of <code>fonction[[2]]</code> and <code>vector1[[1]]</code>, and <code>fonction[[2]]</code> and <code>vector1[[2]]</code>, so a list of 2 in <code>precip.back2</code>.
What I want to have is a list of 4 in <code>precip.back2</code> with the results of:</p>

<pre><code>fonction[[1]] and vector1[[1]], 
fonction[[1]] and vector1[[2]],
fonction[[2]] and vector1[[1]], 
fonction[[2]] and vector1[[2]]
</code></pre>

<p>like in <code>print(z)</code>.</p>

<p>Would you have any advice ?
Best, </p>