Set a dataframe as column names for another data frame

user2603386 picture user2603386 · Jul 24, 2013 · Viewed 8.5k times · Source

So I have a data frame (called SNPlist) which is of dimensions 1 by 500000 (rows by columns). I want SNP list to be the column names for my dataframe of data (called Data) which is of dimension 100 by 500000. I already tried colnames(Data) <- SNPlist but it does not seem to be working. Can anyone help with this issue?

Thanks

Answer

alexwhan picture alexwhan · Jul 24, 2013

If SNPlist is a data.frame, then you need to point to the first row of it:

colnames(Data) <- SNPlist[1, ]

If it was a vector, what you'd tried would have worked