I'm new to R and I learnt data.frame today.
I want to use the first row of my data frame as the column names, but the column names became really wired. Here is a sample of my data:
a <- data.frame(V1 = c("ENSMUSG00000000001_Gnai3", "0.00"), V2 = c("ENSMUSG00000000003_Pbsn", "0.00"), row.names = c("Gene_id", "P1-3-A1"))
a
The outcome is:outcome_1
I want to give the first row as my column names, so I type:
colnames(a) <- a[1,]
But the column names become like this:outcome_2
When I call the column name by using:
colnames(a)
,I got this: "2" "2", instead of "ENSMUSG00000000001_Gnai3", "ENSMUSG00000000003_Pbsn"
question from:
https://stackoverflow.com/questions/65878347/a-newbie-has-a-question-about-data-frame-column-names 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…