Function reading many csv
<p>I created a function that allows to assign csv into variables. However it's not working and I have no idea why. Here's the code: </p>

<pre><code> file_id &lt;- readline("Type a common word for your files: ")
 file_list &lt;- list.files(pattern = file_id)

 multi.csv &lt;- function(pattern.seq)
  {
    for(i in 1:length(pattern.seq))
       {
          assign(pattern.seq[i], read.csv(pattern.seq[i]))
       }
  }

multi.csv(pattern.seq = file_list)

cat(" Now your .csv files are stored in variables: ", file_list) 
</code></pre>

<p>Let me explain what's going on here. Lets assume that I have ten csv. files that differs only by a certain number in their names eg. file_01, file_02... Function list.files reckognizes the pattern in file names and stores it in the char vector c("file_02", "file_02"...). Then I wrote the function multi.csv that should assign the data stored in csv. into variables. However it's not working. What's more, when I call the <code>assign</code> function outside the multi.csv function with a certain element of file_list vector: </p>

<pre><code>assign(file_list[1], read.csv(file_list[1]))
</code></pre>

<p>it works as it should: variable file_01 stores the data from file_01.csv.</p>

<p>Have you got any idea why it's not working inside multi.csv function?</p>

<p>I'm fully aware that the whole problem of reading many csv files can be solved differently but I want to know what's wrong here. </p>