title: How to use blank df and lists to speed up processing time in R
body: <p>I know that creating a blank dataframe or list prior to populating it is a good thing to speed up processing time in R, but I'm having trouble executing it.  Generally, all I would like to do is create a blank list of dataframes in which a map function fills in after completing some filtering.  Below I'll recreate a simplified example to help explain what I'm trying to accomplish.</p>
  <pre><code>library(tidyverse)
  library(purrr)
  library(dplyr)
  </code></pre>
  <p>The code to create the lists of dataframes below is to much to show, but essentially I have a list of 192 dataframes that each contain the same type of information, but the data in each dataframe varies depending on which list.</p>
  <p>&quot;ListofDF1&quot; is a list of 192 dataframes, each containing 468 rows and 27 columns of data. This list of dfs is created using a series of map functions.</p>
  <p>Next, I have a pmap function that performs many tasks.  Too many to show here, but below I'll generally show what I'm trying to accomplish.</p>
  <pre><code>return &lt;-  
    pmap(inputs, function(&quot;variables that are contained in inputs dataframe&quot;) {  
  
      ListofDF2&lt;- map(ListofDF1, ~filter(., 
                   &quot;series of filters&quot;
                         %&gt;% 
                      map(., ~data.frame(.) %&gt;% 
                      select(column1)
  
  }
  </code></pre>
  <p>To summarize, inside the pmap function, a map function is performed on ListofDF1 (192 times because ListofDF1 contains 192 dataframes) to filter various metrics in the ListofDF1.  The result is ListofDF2, which is a list of 192 dataframes.  Note that  each dataframe within the list of dfs contains only 1 column (due to select(column1)).  But the number of rows in each dataframe are NOT consistent as they are dependent on the filtering that occurs.</p>
  <p>I would like to try to improve the speed of my overall pmap function because it is cycling through several thousand times and I believe that creating a blank ListofDF2 may help.</p>
  <p>Therefore, does anyone have any suggestions on how to create the blank ListofDF2 list of dataframes and then populate it using the filtering map function? To clarify, my existing code works just fine.  I am just trying to improve speed and therefore efficiency.</p>
  <p>Additionally, I would also like to crate a blank &quot;return&quot; list for the pmap function to populate.  But one step at a time.</p>