0
我已經使用以下代碼中的R讀取多個文件的.csv的多個文件特定列:閱讀中的R
Assembly<-t(read.table("E:\\test\\exp1.csv",sep="|",header=FALSE,col.names=c("a","b","c","d","Assembly","f"))[1:4416,"Assembly",drop=FALSE])
Top1<-t(read.table("E:\\test\\exp2.csv",sep="|",header=FALSE,col.names=c("a","b","c","d","Top1","f"))[1:4416,"Top1",drop=FALSE])
Top3<-t(read.table("E:\\test\\exp3.csv",sep="|",header=FALSE,col.names=c("a","b","c","d","Top3","f"))[1:4416,"Top3",drop=FALSE])
Top11<-t(read.table("E:\\test\\exp4.csv",sep="|",header=FALSE,col.names=c("a","b","c","d","Top11","f"))[1:4416,"Top11",drop=FALSE])
Assembly1<-t(read.table("E:\\test\\exp5.csv",sep="|",header=FALSE,col.names=c("a","b","c","d","Assembly1","f"))[1:4416,"Assembly1",drop=FALSE])
Area<-t(read.table("E:\\test\\exp6.csv",sep="|",header=FALSE,col.names=c("a","b","c","d","Area","f"))[1:4416,"Area",drop=FALSE])
data<-rbind(Assembly,Top1,Top3,Top11,Assembly1,Area)
所以整個數據是在驅動器E的文件夾的「測試」。在R中有一種更簡單的方法來用多行代碼或某種函數調用來讀取多個.csv數據來替代上面所做的內容?
請參閱[this](http://stackoverflow.com/questions/11433432/importing-multiple-csv-files-into-r)回答。 –
我只需要第5列,我想列出該列。上面的答案不清楚。 –
也許我不明白你在做什麼,但用不同的conames綁定數據框是行不通的:然後它從第一個數據框取得列的類,並按名稱匹配列(而不是按位置)._ – vaettchen