我正在处理一些.xlsx,它们的名称类似time1_drug1,time1_drug2,直到tiume6_drug5(总共30个文件)。我想将这些xlsx加载到R,并将它们命名为t1d1,t2d2等数据集。 感谢您的@ akash87,他的代码解决了这个问题。
新问题是我想重命名名为“ pERK”,“ NGFR”,“ AXL”的列,然后为每个数据创建第四列,并带有名称描述。
%%%these are code I have now
for(i in 1:6){
for(j in 1:5){
assign(paste0('t', i, '_', 'd', j), read.xlsx(paste0("/Users/pathway/dataset/time_",i,"_drug",j,".xlsx"), 1))
}
}
%%%%%%%%%%%%%for a single data, I could use which command, but I don't know what to do in a for loop.
pERKlimit=7
NGFRlimit=3.45
AXLlimit=3.6
names(data11)=c("pERK", "NGFR","AXL")
data11$Discription[which(data11$NGFR>=NGFRlimit&data11$AXL>=AXLlimit)]="NFGR High&AXL High"
data11$Discription[which(data11$NGFR>=NGFRlimit&data11$AXL<AXLlimit)]="NFGR High&AXL Low"
data11$Discription[which(data11$NGFR<NGFRlimit&data11$AXL<AXLlimit)]="NFGR Low&AXL Low"
data11$Discription[which(data11$NGFR<NGFRlimit&data11$AXL>=AXLlimit)]="NFGR Low&AXL High"
我希望使用for循环来解决重命名列和创建第四列的问题。