title: R gsub column names in all data frames within a list
body: <p>I have a list of data frames with column names that I want to substitute some strings out, but I can't do it right.</p>
  
  <pre><code>list:
  [1]
  cpg value.TCGA.06.5415.01A     value.TCGA.02.0003.01A   value.TCGA.16.1062.01A
  cg02726808  0.934641544 NA  NA
  cg04243127  0.8828403   NA  NA
  [2]
  cpg value.TCGA.QH.A6CV.01A  value.TCGA.E1.A7Z4.01A  value.TCGA.E1.5303.01A
   cg02726808 0.938556343 0.92163563  0.959269597
   cg04243127 0.886928811 0.842963126 0.937700666
  [N]
  .....
  
  Desired output:
      list:           
  [1]         
  cpg 06.5415.01A 02.0003.01A 16.1062.01A
  cg02726808  0.934641544 NA  NA
  cg04243127  0.8828403   NA  NA
  [2]         
  cpg QH.A6CV.01A E1.A7Z4.01A E1.5303.01A
  cg02726808  0.938556343 0.92163563  0.959269597
  cg04243127  0.886928811 0.842963126 0.937700666
  [N]         
  .....
  </code></pre>
  
  <p>I tried to write the following:</p>
  
  <pre><code>lapply(lst, function(x) { gsub("value.TCGA.", "", colnames(lst[[x]]))})
  </code></pre>
  
  <p>Error in R Studio:</p>
  
  <pre><code>Error in llis1[[xy]] : invalid subscript type 'list'
  Called from: is.data.frame(x)
  Browse[1]&gt; 
  </code></pre>
  
  <p>And I don't understand what is it about. Thanks for your help.</p>