title: Adding column depending on another column of a list object
body: <p>I have a list object in R </p>
  
  <pre><code> dl &lt;- list(matrix(c(1,5,.2,.7), nrow=2,dimnames=list(c(),c("x","y"))), matrix(c(0,1,.01,.4), nrow=2,dimnames=list(c(),c("x","y") )))
  </code></pre>
  
  <p>I want to add another column <code>z &lt;- rbinom(2,1,y)</code> with each element of the list. That is <code>z</code> is a bernoulli random variable with probability vector <code>y</code> of each list. So far I did:</p>
  
  <pre><code>a=dl[[1]]
  a=data.frame(a)
  a$z &lt;- with(a, rbinom(2,1,y))
  
  b=dl[[2]]
  b=data.frame(b)
  b$z &lt;- with(b, rbinom(2,1,y))
  </code></pre>
  
  <p>But this coding looks messy. </p>