I've seen this asked here: Create header of a dataframe from the first row in the data frame
and here: assign headers based on existing row in dataframe in R
and the solutions offered don't work for me.
When I transpose my dataframe (p1), the header of DF.transpose (p1t) is something new and annoying. and the first row of the p1t is what I would like to use as the header, I tried:
colnames(p1t) = p1t[1, ]
and it doesn't work!
here is how the original df appears:
File Fp1.PD_ShortSOA_FAM Fp1.PD_LongSOA_FAM Fp1.PD_ShortSOA_SEMplus_REAL Fp1.PD_ShortSOA_SEMplus_FICT
sub0001 0,446222 2,524,804 0,272959 1,281,349
sub0002 1,032,688 2,671,048 1,033,278 1,217,817
And here is how the transpose appears:
row.names V1 V2
File sub0001 sub0002
Fp1.PD_ShortSOA_FAM 0,446222 1,032,688
Fp1.PD_LongSOA_FAM 2,524,804 2,671,048
Fp1.PD_ShortSOA_SEMplus_REAL 0,272959 1,033,278
Fp1.PD_ShortSOA_SEMplus_FICT 1,281,349 1,217,817
Fp1.PD_ShortSOA_SEMminus_REAL 0,142739 1,405,100
Fp1.PD_ShortSOA_SEMminus_FICT 1,515,577 -1,990,458
How can I make "File", "sub0001","sub0002" etc... as the header?
Thanks!