title: store for loop values in variable in R
body: <p>I am using a for loop obtain a set of p-values using the "pbinom" function. The values 1:5 simply refer to the number of observed counts, 21, refers to the sample size, and 0.05 refers to the probability of success:</p>
  
  <pre><code>for ( i in 1:5) {
  print (1 - pbinom(i, 21, 0.05))
  }
  
  [1] 0.2830282
  [1] 0.08491751
  [1] 0.01888063
  [1] 0.00324032
  [1] 0.0004415266
  </code></pre>
  
  <p>This code works fine, but it just outputs the values the values on the command prompt as above.</p>
  
  <p>My question is, how can I store the output in a variable?</p>
  
  <p>I tried</p>
  
  <pre><code>output&lt;-for ( i in 1:5) {
  print (1 - pbinom(i, 21, 0.05))
  }
  </code></pre>
  
  <p>But when I entered "output", I received "NULL" in response.</p>
  
  <p>Any help would be appreciated,
  Thanks.</p>