Using lapply to change column names of a list of data frames
问题 I'm trying to use lapply on a list of data frames; but failing at passing the parameters correctly (I think). List of data frames: df1 <- data.frame(A = 1:10, B= 11:20) df2 <- data.frame(A = 21:30, B = 31:40) listDF <- list(df1, df2,df3) #multiple data frames w. way less columns than the length of vector todos Vector with columns names: todos <-c('col1','col2', ......'colN') I'd like to change the column names using lapply: lapply (listDF, function(x) { colnames(x)[2:length(x)] <-todos[1