title: confused in understanding an rbinom output
body: <pre><code>  p1 &lt;- c(.25,.025,.025,.1,.2,.4)
  
    T &lt;- sample(1:6,size=N,replace=TRUE, prob=someprobabilityvector)
    Y &lt;- rbinom(N,1,p1[c(T)])
  </code></pre>
  
  <p>HI folks, I am new to R and programming in general and need some help with understanding sth basic. could someone explain to me one what is happening in vector Y above. I figure out what <code>p1[c(T)]</code> does above. But have no idea what vector Y is doing. All help is appreciated in advance.</p>