我對R很陌生,並且使用別人寫的腳本。初級講座在這裏我得到一個錯誤信息的腳本的一部分:未定義列選擇R中的錯誤消息
錯誤
[.data.frame
(this.df.merged,C( 「MMWR_week」, 「證 訪問」:選擇未定義列
我擡頭其他repsonses類似的問題,並不能真正找到我的解決方案。任何幫助,將不勝感激。
if (!("other" %in% colnames(this.df.merged))) {
this.df.merged$other<-0
}
this.df.merged.by_week<-aggregate(this.df.merged[c("Syndrome Visits","E","other","0-4","25-49","5-24","50-64","over 64","F","M","U","Admit","Disch")],by=list(this.df.merged$MMWR_week),sum)
colnames(this.df.merged.by_week)<-c("MMWR_week","Syndrome Visits","E","other","0-4","25-49","5-24","50-64","over 64","F","M","U","Admit","Disch")
write.csv(this.df.merged.by_week, file=paste(this.diseaseName,"_Count_Query_Summary_Table_by_Week_",this.beginDate,"_",this.endDate,".csv",sep=""))
return(this.df.merged)
}
pleasemakeyourcodemorereadable – 2014-10-17 18:54:50
似乎不太可能會有一個列名「綜合症訪問」(中間有空格前在裏面)。 'name(this.df.merged)'是什麼。當發佈一個問題時,請花時間包含一個[可重現的示例](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example),否則我們沒有想法你正在使用的物體的結構是什麼,這使得很難幫助你。 – MrFlick 2014-10-17 19:13:53
感謝理查德,仍然試圖得到這個竅門。你的建議似乎是正確的,我不認爲存在綜合徵。我會更多地考慮這一點,感謝評論。 – Enrique 2014-10-17 19:25:33