title: apply function to column names using a list of data frames
body: <p>I'm trying to apply a very complex function to a list of more than 50 Data Frames.
  Let's use a very simple function to lowercase names and just 3 data frames for the sake of clarity, but my general approach is coded below</p>
  
  <pre><code>[EDITED NAMES]
  # Data Sample. Every column name is different accross Data Frames
  
  
  quality &lt;- data.frame(FIRST=c(1,5,3,3,2), SECOND=c(3,6,1,5,5))
  thickness &lt;- data.frame(THIRD=c(6,0,9,1,2), FOURTH=c(2,7,2,2,1))
  distance &lt;- data.frame(ONEMORE=c(0,0,1,5,1), ANOTHER=c(4,1,9,2,3))
  
  
  # list of dataframes
  
  dfs &lt;- list(quality, thickness, distance)
  
  
  # a very simple function (just for testing)
  # actually a very complex one is used on real data
  
  BetterNames &lt;- function(x) {
      names(x) &lt;- tolower(names(x))
    x
  }
  
  
  # apply function to data frame list
  
  dfs &lt;- lapply(dfs, BetterNames)
  
  # I know the expected R behaviour is to modify a copy of the object,
  # instead of the original object itself. So if you get the names
  # you get the original version, not the needed one
  
  names(quality)
  
  [1] "FIRST"  "SECOND"
  </code></pre>
  
  <p>is there any way of using any function inside a loop or "apply" in place for a huge amount of data frames?<br>
  As a result we must get the modified one replacing the original one for every data frame in the list (big list)</p>
  
  <p>I know there's a trick using Data Table, but I wonder if using base R is that possible.</p>
  
  <p>Expected Results:</p>
  
  <pre><code> names(quality)
  
      [1] "first"  "second"
  </code></pre>
  
  <p>[EDITED]
  Pointed out to this answer:  <a href="https://stackoverflow.com/questions/18375969/rename-columns-in-multiple-dataframes-r">Rename columns in multiple dataframes, R</a></p>
  
  <p>But not working. You can't use a vector of string names in my case because my new names are not a fixed list of strings.[EDITED DATA]</p>
  
  <pre><code>for(df in dfs) {
    df.tmp &lt;- get(df)
    names(df.tmp) &lt;- BetterNames(df)
    assign(df, df.tmp)
  }
  
  &gt; names(quality)
  [1] "quality" NA  
  </code></pre>
  
  <p>Thanks</p>