title: recursively split list elements
body: <p>I cannot find the right incantation of <code>Reduce</code>, <code>Recall</code>, <code>lapply</code> to perform the following task. Consider the following function,</p>
  
  <pre><code>bisect.df &lt;- function(d){
    n &lt;- ncol(d)
    if(n%%2) n &lt;- n-1 # drop one col if odd number
    ind &lt;- sample(n)[seq.int(n/2)] # split randomly both parts
  
    list(first=d[, ind],
         second=d[, -ind])
  }
  </code></pre>
  
  <p>given a <code>data.frame</code>, it returns a list of two children <code>data.frames</code> of equal <code>ncol</code> extracted randomly from their parent. I wish to apply this function recursively to the offsprings down to a given level, say 3 generations. I can do it trivially one generation at a time,</p>
  
  <pre><code>bisect.list &lt;- function(l){
    unlist(lapply(l, bisect.df), recursive=FALSE)
  }
  </code></pre>
  
  <p>but how do I call this recursively, say <code>N=3</code> times?</p>
  
  <p>Here's a test sample to play with</p>
  
  <pre><code>d &lt;- data.frame(matrix(rnorm(16*5), ncol=16))
  step1 &lt;- bisect.list(list(d))
  step2 &lt;- bisect.list(step1)
  step3 &lt;- bisect.list(step2)
  str(list(step1, step2, step3))
  </code></pre>