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.
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
#add diferent prefixes to all col names
colnames(iris)<-paste('iris_',colnames(iris), sep='')
colnames(mtcars)<-paste('mt_',colnames(mtcars), sep='')
colnames(ToothGrowth)<-paste('TG_',colnames(ToothGrowth), sep='')
#create list of data frames
mylist<-list(iris, mtcars, ToothGrowth)
#name elements of list
names(mylist)<-c('iris','mtcars','ToothGrowth')
#remove prefix from colnames individually for each data frame
colnames(mylist['iris']$iris)<-sub('[^.]+\\_', '', colnames(mylist['iris']$iris))