A simple function to rename columns in data frame to standardized names in R I wrote this simple function to rename columns in a data frame to standardized names in R. This function is useful when we have a very large data set with large number of columns especially for machine learning applications.

colRename&lt;-function(x){  
  for(i in 1:ncol(x)){
    colnames(x)[i] &lt;- paste("column",i,sep="")
  }  
  return(x)
}


An example

library(quantmod)

colRename&lt;-function(x){  
  for(i in 1:ncol(x)){
    colnames(x)[i] &lt;- paste("column",i,sep="")
  }  
  return(x)
}

aapl=getSymbols("AAPL",from="2015-01-01",auto.assign=F)
head(colRename(aapl))


Result

           column1 column2 column3 column4  column5  column6
2015-01-02  111.39  111.44  107.35  109.33 53204600 105.6986
2015-01-05  108.29  108.65  105.41  106.25 64285500 102.7209
2015-01-06  106.54  107.43  104.63  106.26 65797100 102.7306
2015-01-07  107.20  108.20  106.70  107.75 40105900 104.1711
2015-01-08  109.23  112.15  108.70  111.89 59364500 108.1736
2015-01-09  112.67  113.25  110.21  112.01 53699500 108.2896
Most R functions are vectorized, you don't need the for loop:

colRename &lt;- function(x) {
   setNames(x, paste0("column", seq_len(ncol(x))))
}