2013-06-19 19 views
0

我有一個24個PAIR文件的列表。 我想將每個PAIR文件與NDF文件合併,產生24個合併的pair-ndf文件。 目標是編寫每個合併文件以從文件中提取信息以創建XYS文件。 但是,在這裏,我試圖執行一個循環函數來將NDF文件與24個PAIR文件中的每一個合併。如何合併一個文件與列表中的多個文件以使用循環功能在R中生成多個合併文件

#read in files 
allfilesList=lapply(list.files(), read.delim, header=TRUE, sep="\t", as.is=TRUE) 

#read files in a list, and merge each file with ndf using loop function to merge, Attempt#1 
for(file in allfileslist){ 
if(!exists("dataset")){ 
dataset=read.table(allfileslist, header=TRUE, sep="\t", as.is=TRUE) 
} 
for(file in allfileslist){ 
if(exists("dataset")){ 
temp_dataset=read.table(allfileslist, header=TRUE, sep="\t") 
dataset=merge(file, ndf, by="PROBE_ID", temp_dataset) 
rm(temp_dataset) 
} 
} 
#read files in a list, and merge each file with ndf using loop function to merge, Attempt#2 
for(i in 1:length(allfileslist)){ 
readnmerge=read.delim(file=paste(getwd(), allfileslist[i], sep="\t"), header=T) 
dataMerge=merge(readnmerge, ndf, by="PROBE_ID") 
} 

但是,這兩種情況似乎只遍歷一個文件,IMAGE_ID是每個PAIR文件中的第一列。

我會繼續努力。儘管如果有人可以提出更好的方法,請回復。 問候, FRANKLIN

+0

for循環應該是'dataset = read.table(file,...)'嗎? – Hugh

回答

0

它已經一段時間,所以我想我幫忙回答我的問題。 另外,我在Bioconductor中找到了pdInfoBuilder和Oligo軟件包。 有一種方法可以使用R將對轉換成xys文件。 我在這裏找到了這篇文章: Manipulating multiple files in R 這是非常有幫助的。