out_con
write(sprintf("This is line %d.\n",1),out_con,append=T)
write("This is line 2.",out_con,append=T)
close(out_con)
或者printer = file("out.txt","w")
writeLines("This is line.",con=printer,sep=" ")
writeLines("The same line.",con=printer)
close(printer)
参考:
也可以用sinksink("tmp_out.txt")
con
line
while(length(line) != 0) {
c = unlist(strsplit(line, "\t"))
if (c[1] == "Contig") {
#k_test
cat(line)
cat("\n")
}
else if (as.numeric(c[1]) %in% g.out$name) {
##a
##k_test
cat(line)
cat("\n")
}
line = readLines(con, n=1)
}
close(con)
sink()