我正在表演:
for(i in c(1:4)){
colnames(eval(parse(text = paste0("tabDummy",i)))) <- c("RM", "IVS", "COR", "ANO")
}
但是R返回以下错误消息:
Error in colnames(eval(parse(text = paste0("tabDummy", i)))) <- c("RM", :
target of assignment expands to non-language object
答案 0 :(得分:1)
可能是这样的:
df
是您的数据框
y = c("RM", "IVS", "COR", "ANO")
for( x in 1:4 ){
colnames(df)[ colnames(df) == paste0("tabDummy", x) ] <- y[x]
}