I am relatively new to R, and am facing an issue trying to convert the first row of a list of dataframe into the column name.
I have a dataframe of 120 rows, the dp
Your function inside lapply
returns x[1, ]
only. You have to return the whole data frame instead. Use this command:
lapply(cmonlist, function(x) "names<-"(x, x[1, ]))
If you also want to remove the first row of each data frame, use this:
lapply(cmonlist, function(x) tail("names<-"(x, x[1, ]), -1))