title: Convert R apply statement to lapply for parallel processing
body: <p>I have the following R "apply" statement:</p>
  
  <pre><code>for(i in 1:NROW(dataframe_stuff_that_needs_lookup_from_simulation))
  {
      matrix_of_sums[,i]&lt;-
      apply(simulation_results[,colnames(simulation_results) %in% 
      dataframe_stuff_that_needs_lookup_from_simulation[i,]],1,sum)
  }
  </code></pre>
  
  <p>So, I have the following data structures:</p>
  
  <p><strong>simulation_results:</strong> A matrix with column names that identify every possible piece of desired simulation lookup data for 2000 simulations (rows).</p>
  
  <p><strong>dataframe_stuff_that_needs_lookup_from_simulation:</strong> Contains, among other items, fields whose values match the column names in the simulation_results data structure.</p>
  
  <p><strong>matrix_of_sums:</strong> When function is run, a 2000 row x 250,000 column (# of simulations x items being simulated) structure meant to hold simulation results. </p>
  
  <p>So, the apply function is looking up the dataframe columns values for each row in a 250,000 data set, computing the sum, and storing it in the matrix_of_sums data structure. </p>
  
  <p>Unfortunately, this processing takes a very long time. I have explored the use of rowsums as an alternative, and it has cut the processing time in half, but I would like to try multi-core processing to see if that cuts processing time even more. Can someone help me convert the code above to "lapply" from "apply"?</p>
  
  <p>Thanks!</p>