Set a dataframe as column names for another data frame

dataframe, r, r-colnames

Solution

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

Problem

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?

Original source