title: Subsetting a large list and recombining into a dataframe
body: <p>Say I have a list in R that has a lot of elements. They are structured like the example below (SYMBOLX 1999, SYMBOLX 2000, SYMBOLY 1999, SYMBOLY 2000, etc). I am trying to for each symbol put the years together (rbind) and then for the entire set of symbols put the newly combined years together into one dataframe (cbind).</p>
  
  <p>Right now the code below seems pretty slow when I do it on even a list of 2600 elements. Could anyone suggest a more efficient way to accomplish this?</p>
  
  <p>I made a hopefully reproducible example below (the actual values are not important, just random for now).</p>
  
  <pre><code>symbols &lt;- c("SYMBOLX","SYMBOLY")
  
  first &lt;- structure(list(`_id` = "123182914914", symbol = "SYMBOLX", 
                          year = 1999, monthly = data.frame("COL2"=runif(10, -0.03, 0.03))),
                          .Names = c("_id", "symbol", "year", "monthly"))
  second &lt;-structure(list(`_id` = "123182914915", symbol = "SYMBOLX", 
                          year = 2000, monthly = data.frame("COL2"=runif(10, -0.03, 0.03))),
                          .Names = c("_id", "symbol", "year", "monthly"))
  
  third &lt;- structure(list(`_id` = "123182914916", symbol = "SYMBOLY", 
                          year = 1999, monthly = data.frame("COL2"=runif(10, -0.03, 0.03))),
                          .Names = c("_id", "symbol", "year", "monthly"))
  fourth &lt;- structure(list(`_id` = "123182914917", symbol = "SYMBOLY", 
                           year = 2000, monthly = data.frame("COL2"=runif(10, -0.03, 0.03))),
                           .Names = c("_id", "symbol", "year", "monthly"))
  
  big_list &lt;- list(first,second,third,fourth)
  
  unique_years &lt;- unique(unlist(lapply(big_list, '[[', 'year')))
  
  all_data &lt;- vector(mode = "list", length = length(symbols))
  for (i in 1:length(symbols)) {
    xts_data &lt;- do.call("rbind", lapply(big_list[((length(unique_years)*(i-1))+1):(length(unique_years)*i)], '[[', 'monthly'))
    colnames(xts_data) &lt;- symbols[i]
    all_data[[i]] &lt;- xts_data
  }
  # create final output combined dataframe
  master_data &lt;- do.call("cbind", lapply(all_data, function(x) x))
  </code></pre>