r - How to change column names in dataframe in the loop? -


i have 10 (for example) dataframes similar names df1,df2,df3,... 10 columns i'd give names 10th column in each dataframe dataframe name(10th column in df1 must has "df1" name, in df2 -- "df2" , etc)

i tried this

for (i in paste0("df",1:10)){      assign(names(get(i))[10],             value=i             )      } 

but nothing changed how can solve problem?

you can make in 3 steps :

--get

--change colnames

-- assign

for (i in paste0("df",1:3)){   d=get(i)   colnames(d)[10]=i   assign(i,d) } 

Comments