我有一组数据框,我正在努力更改其上的列名
for(i in c("ML","HL","MSMS","PEP","MqNormHM","MixHM","RawHM","AbsHM","SepAbsHM")){
j<-ifelse(i %in% c("ML","HL","MSMS","PEP","MqNormHM"),paste("Rel",i,sep=""),i)
colnames(get(j))<-paste(i,colnames(get(j)),sep="")
}
给我:
Error in colnames(get(j)) <- paste(i, colnames(get(j)), sep = "") :
could not find function "get<-"
ML、HL 等是以下形式的单个数据帧:
> head(RelML)
AA BB CC DD EE LL MM NN
2684 0.19650 NA NA NA NA NA NA NA
4470 NA NA NA NA NA 0.35249 NA 0.35797
3619 0.22108 0.098167 0.041080 NA NA NA NA NA
5422 NA NA 0.052223 NA NA NA NA NA
1286 NA NA NA NA 0.019568 NA 0.31137 0.34364
1918 NA NA NA 0.026735 NA NA NA NA
并且在所有情况下,数据框的名称都开始为,例如:
> colnames(RelML)
[1] "AA" "BB" "CC" "DD" "EE" "LL" "MM" "NN"
我希望它最终成为 RelML 数据框的情况:
> paste("ML",colnames(RelML),sep="")
[1] "MLAA" "MLBB" "MLCC" "MLDD" "MLEE" "MLLL" "MLMM" "MLNN"
我尝试过使用 get(colnames(j))、colnames(as.name(j)) 等等,但似乎没有任何效果。任何帮助将不胜感激。问候马德斯