I tried some options from stackoverflow(e.g.1) but this also doens't work so maybe there is a mistake in my code:
fileConn<-file("outputR.txt")
for (i in 1:length(lines)){
line = lines[i]
fields = strsplit(line, "\t")[[1]]
id = fields[1]
goIDs = fields[2:length(fields)]
list = as.list(GOCCANCESTOR[goIDs])
text = paste(toString(id), ":", toString(goIDs))
cat(text, file=fileConn, append=TRUE, sep = "\n")
}
close(fileConn)
when I run this code it keeps overwriting the data in the outputR.txt file. Any suggestions to fix this problem?