我想根据另一个数据框的列中的名称来命名我的列名。我想根据isomir_Hep
在ClinicalDataHep$NamesClean
中订购名称。有没有办法做到这一点?
> ClinicalDataHep$NamesClean
[1] 1018 1065 1068 1104 1167 1196 1222 1237 1241 1302 1304
[12] 1322 1372 1474 1532 1540 1588 1604 1743 1808 1809 1859
[23] 1894 2218 2239 HEP014 HEP015 018 020 045 mm7 d10 s26
[34] vs29 21 27 32 bf33 38 39 45 46 TxHEP-014 TxHEP-015
[45] TxHEP-018 080 082 084 086 088 090 091 092 094 096
[56] 102 112 113 120 121 134 140 144 145 146 157
[67] 158 161 164 176 185 186 192 201 204 215 236
77 Levels: 018 020 045 080 082 084 086 088 090 091 092 094 096 1018 102 1065 1068 1104 112 113 1167 1196 120 ... vs29
> names(isomir_Hep)
[1] "092" "112" "121" "164" "TxHEP-014" "TxHEP-018" "082" "084" "mm7"
[10] "086" "088" "094" "096" "102" "113" "120" "134" "140"
[19] "144" "d10" "145" "146" "157" "158" "161" "176" "185"
[28] "186" "192" "201" "s26" "204" "215" "236" "21" "27"
[37] "32" "38" "39" "45" "46" "vs29" "1018" "1065" "1068"
[46] "1104" "1167" "1196" "1222" "1237" "1241" "1302" "bf33" "1304"
[55] "1322" "1372" "1474" "1532" "1540" "1588" "1743" "1808" "TxHEP-015"
[64] "1809" "1859" "1894" "2218" "2239" "104" "HEP014" "HEP015" "HEP018"
[73] "020" "080" "045" "090" "091"
答案 0 :(得分:0)
创建一个名为newClinicalDataHep
的新数据框并循环遍历它,以便根据names(isomir_Hep)
按行排序重新填充它。
#Initialize newClinicalDataHep
newClinicalDataHep <- ClinicalDataHep[which(ClinicalDataHep$NamesClean==names(isomir_Hep)[1]),]
#Loop through to repopulate it
for(i in 2:length(names(isomir_Hep))){
newClinicalDataHep <- rbind(newClinicalDataHep , ClinicalDataHep[which(ClinicalDataHep$NamesClean==names(isomir_Hep)[i]),]
}