title: Nested for loop to generate random variables with differing probabilities in R
body: <p>I am trying to write a for loop that generates random variables from a geometric distribution using different probability values. However, the code I write only uses the last probability in the sequence to generate the random variables, see below.</p>
  <pre><code>x &lt;- list()
  y &lt;- list()
  probs &lt;- seq(0.1, 0.9, 0.1)
  for (i in 1:length(probs)) {
    for (j in 1:10000) {
      x[j] &lt;- rgeom(n=1, prob=probs[i])+1
      y[j] &lt;- probs[i]
    }
  }
  </code></pre>
  <p>How do I loop along the probabilities to generate 10000 RV for each probability?</p>