title: Remove part of col names in list of data frames - R
body: <p>In this dummy list of data frames, all column names have a prefix followed by an underscore. Each data frame in the list has a different prefix, but they all include an underscore. </p>
  
  <p>How can I remove the underscore and the text before it in the column names of all data frames in the list? I can do it individually, but my real list contains many more data frames. Thank you</p>
  
  <pre><code>#add diferent prefixes to all col names
  colnames(iris)&lt;-paste('iris_',colnames(iris), sep='')
  
  colnames(mtcars)&lt;-paste('mt_',colnames(mtcars), sep='')
  
  colnames(ToothGrowth)&lt;-paste('TG_',colnames(ToothGrowth), sep='')
  
  #create list of data frames
  
  mylist&lt;-list(iris, mtcars, ToothGrowth)
  
  #name elements of list
  
  names(mylist)&lt;-c('iris','mtcars','ToothGrowth')
  
  #remove prefix from colnames individually for each data frame
  
  colnames(mylist['iris']$iris)&lt;-sub('[^.]+\\_', '', colnames(mylist['iris']$iris))
  </code></pre>