I currently have a while loop to read HTML tables and in each loop I would like to change the column names to the first row of the current data frame. Let's say I have a data frame named "df1". I could accomplish this with the following code:
colnames(df1) = unlist(df1[1,])
And that works fine, but I can't specify df1 in the loop because it could be df1, df2, and so on depending on what i equals.
I wrote the following code:
colnames(eval(parse(text=paste0("df",1)))) = unlist(eval(parse(text=paste0("df",1)))[1,])
I replaced i with 1 for testing purposes, but I get the following error:target of assignment expands to non-language object
If I run colnames(eval(parse(text=paste0("df",1)))) on its own, the data looks the same as colnames(df1) and same with unlist(eval(parse(text=paste0("df",1)))[1,]) looking like unlist(df1[1,]).
Any help on this will be much appreciated!
