title: How to make a functional list with the data.frames from the environment in R?
body: <p>I want to join several data.frames in one. All the data.frames share an identical column.</p>
  <p>There are <a href="https://stackoverflow.com/questions/14096814/merging-a-lot-of-data-frames">different ways</a> to merge several datasets and since I am using this approach <code>Reduce(function(...) merge(..., all=TRUE), list(  ))</code> I need to get a list of the data.frames that I have in the environment.
  However, every time that I try to get a list of them, the features of being a data.frame disappear and they are only saved as a names.</p>
  <p>These are my dataframes:</p>
  <pre><code>file_1 &lt;- women
  file_2 &lt;- women
  colnames(file_2) &lt;- c(&quot;height_2&quot;, &quot;weight_2&quot;)
  file_3 &lt;- women
  colnames(file_3) &lt;- c(&quot;height_3&quot;, &quot;weight_3&quot;)
  file_4 &lt;- women
  colnames(file_4) &lt;- c(&quot;height_4&quot;, &quot;weight_4&quot;)
  file_5 &lt;- women
  colnames(file_5) &lt;- c(&quot;height_5&quot;, &quot;weight_5&quot;)
  </code></pre>
  <p>Since I want to merge them, I need to add the same column to all of them.
  With the first line of code, I make a list of the variables that I have in the environment (I only want the data.frames which start with the name &quot;file&quot;)</p>
  <pre><code>list_files &lt;- grep(&quot;file&quot;,names(.GlobalEnv),value=TRUE)
  
  for (file in list_files){
    temp &lt;- get(file)
    # We add the column 
    temp$ID &lt;- &quot;col&quot;
    #we return the change in the file
    assign(file, temp)
  }
  rm(temp) #we don't need it anymore.
  </code></pre>
  <p>However, when I try to use <code>list_files</code> (which has the name of the data.frames) in order to merge them, I don't get a proper data.frame merged.</p>
  <pre><code>DF_complete &lt;- Reduce(function(...) merge(..., all=TRUE), list(list_files))
  
  &gt; class(DF_complete)
  [1] &quot;character&quot;
  </code></pre>
  <p>On the other hand, when I try this code (I write all the dataframes myself), I get the dataframe that I want.</p>
  <pre><code>DF_2 &lt;- Reduce(function(...) merge(..., all=TRUE), list(file_1, file_2, file_3, file_4, file_5))
  
  class(DF2)
  [1] &quot;data.frame&quot;
  </code></pre>
  <p>I want to avoid writing all the data.frames. Right now I have 5 data.frames, but when I have more than 10.... it will be tough. For that reason, I want to find another way.</p>
  <p>I saw this <a href="https://stackoverflow.com/questions/20812132/how-to-save-data-frames-respectively-in-a-list">post</a> and I have tried this, but they are not saved as data.frames.</p>
  <pre><code>list_df &lt;- list(list_files)
  &gt; list_df
  [[1]]
  [1] &quot;file_1&quot; &quot;file_2&quot; &quot;file_3&quot; &quot;file_4&quot; &quot;file_5&quot;
  class(list_df)
  [1] &quot;list&quot;
  </code></pre>
  <p>Does anyone know how to do it?</p>
  <p>Thanks very much in advance</p>