[R] appending collums in for loop

Who Am I? s1008701 at student.hsleiden.nl
Tue Mar 22 15:56:04 CET 2011


Got it working with a package called 'xlsReadWritePro' (which requires a
license after 30 day's...) This is my code:
setwd("J:/Stage/Datasets2/Datasets/outData")

masterTable<-read.table("AR1000900A_N_241110_(Mapping250K_Nsp)_2,Mapping250K_Nsp,CNprobes.tab
_SNP_IDs.xls",sep="\t", dec=",", fill=T, header=T)
masterTable<-data.frame(masterTable)

fileNames<-list.files(getwd(), pattern='_0,5 -0,51.xls')
library(xlsReadWritePro)
regionMatchM<-data.frame()
write.xls(regionMatchM, file= "Array012345.xls")                                                               
for(i in 1:5) {
		fileName <- fileNames[i]
    newFile <- file.path(getwd(), paste(fileNames[i], "samen_0,5
-0,51.xls"))
		snpidFile<-read.table(fileNames[i],sep="\t", dec=",", fill=T, header=T)
    snpidFile<-data.frame(snpidFile)
		regionMatch<-cbind(masterTable, snpidFile[match(masterTable$Pos,
snpidFile$Pos),])
    regionMatchABCDE<-data.frame(regionMatch[10:18])
    write.xls(regionMatchABCDE, file= "Array012345.xls", naStrings = "NAN",
append=T, from= c(1,(1+i)*9), rowNames=FALSE)
}
genomeInfo<-read.xls("Array012345.xls")
len<-length(genomeInfo[1,])
finalTable<-data.frame(masterTable, genomeInfo[,18:len])
summary(finalTable)
write.table(finalTable, file= "Array012345_final1.xls", append=F,
col.names=T, row.names=F, quote=F, sep = "\t")

Thanks for the help anyway. If someone has a solution for this problem,
without the need of a package, please reply

--
View this message in context: http://r.789695.n4.nabble.com/appending-collums-in-for-loop-tp3393446p3396610.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list