title: How do I repetitively create global variables from inside a function, each with a different name?
body: <p>I start with a list of tables, each with the same column names, but different numbers of rows:</p>
  
  <pre><code>filenames&lt;- c('name1','name2','etc')
  dat&lt;-lapply(paste(filenames,'.csv',sep=""),read.csv)
  </code></pre>
  
  <p>Then I name each table in my list:</p>
  
  <pre><code>names(dat)&lt;-filenames
  </code></pre>
  
  <p>Then I write a function to do various things with the data:</p>
  
  <pre><code>myfunc&lt;- function (data) {results.table&lt;-some.operations(data)}
  </code></pre>
  
  <p>I want to run my function repetitively over each table in 'dat':</p>
  
  <pre><code>lapply(filenames, function(x) myfunc(dat[[x]],x))
  </code></pre>
  
  <p>I am looking for some line to put in 'myfunc' that will create a global output table with a unique name for each table in 'dat' so that I can search these outputs. I understand the global operator &lt;&lt;- creates a global variable, but I'm having trouble figuring out how to assign the names. I tried</p>
  
  <pre><code>name&lt;&lt;-results.table
  </code></pre>
  
  <p>but that just assigns each result table to the global variable 'name' so I only have one output at the end - the results for the last table the function ran on. I also tried</p>
  
  <pre><code>paste(name)&lt;&lt;-results.table
  </code></pre>
  
  <p>and</p>
  
  <pre><code>substitute(name)&lt;&lt;-results.table
  </code></pre>
  
  <p>to no avail. Any advice would be much appreciated!</p>