title: Automating object naming when importing multiple files in R
body: <p>So, I downloaded a dataset containing 900 txt files, one for each biological sample. What I want to do is merge all of this data into one data matrix in R.</p>
  
  <pre><code>txt_files = list.files()
  
  # read txt files into a list 
  for (i in length(txt_files)){
    x &lt;- read.table(file=txt_files[i], sep="\t", header=TRUE, row.name=1)
  }
  </code></pre>
  
  <p>All files are in one folder, so I use <code>list.files()</code> to query all file names. Then I want to read each table into a separate R object (which is called x in this case). The problem is that I would like to name each object after the name of the actual file instead of x.</p>
  
  <p>I've tried a couple of things and tried to search the internet, but haven't found a solution yet.
  One thing I did find was to use lapply to import them all into a data list.</p>
  
  <pre><code>data_list = lapply(txt_files, read.table, sep = "\t")
  </code></pre>
  
  <p>However, I don't think this will be appropriate for me, since the data matrixes are not available anymore after this. I hope someone can help me. </p>