I have a csv file (myNames) with column names. It is 1 x 66. I want to use those names to rename the 66 columns I have in another dataframe. I am trying to use colnames(df)[]<-(myNames)
but I get the wrong result. I have tried to do this using as.vector, as.array, as.list, without success.
- Is there a more direct way to read a csv file into an array? or
- How can I get an array from my dataframe that I can use in colnames()?
Here's myNames:
v1 v2 v3 v4 v5 v6 v7
Tom Dick Harry John Paul George Ringo
I want to make Tom, Dick, Harry my new column names in mydata.
colnames(df) <- as.character(unlist(myNames[1,]))
? Also,see?scan
– Ben Bolker