title: Using lapply to change column names of a list of data frames
body: <p>I'm trying to use <strong>lapply</strong> on a list of data frames; but failing at passing the parameters correctly (I think). </p>
  
  <p>List of data frames:</p>
  
  <pre><code>df1 &lt;- data.frame(A = 1:10, B= 11:20)
  df2 &lt;- data.frame(A = 21:30, B = 31:40) 
  
  listDF &lt;- list(df1, df2,df3)    #multiple data frames w. way less columns than the length of vector todos
  </code></pre>
  
  <p>Vector with columns names:</p>
  
  <pre><code>todos &lt;-c('col1','col2', ......'colN')
  </code></pre>
  
  <p>I'd like to change the column names using lapply:</p>
  
  <pre><code>lapply (listDF, function(x) { colnames(x)[2:length(x)] &lt;-todos[1:length(x)-1] }  )
  </code></pre>
  
  <p>but this doesn't change the names at all. Am I not passing the data frames themselves, but something else? I just want to change names, not to return the result to a new object.</p>
  
  <p>Thanks in advance,     p.</p>