R语言字符串写入文件

   out_con  & lt;作用;文件(“out.txt”,“w”)   写(sprintf(“却;能够is  line  % d。\ n”, 1), out_con,附加=T)   写(“却;能够is  line  2。”, out_con,附加=T)   关上(out_con)


或者

printer =,文件(“out.txt”、“w”)   writeline(“却;能够is 行。”,反对=打印机,9=?”)   writeline (“, same 行。”,反对=打印机)   关上(打印机)

参考:http://grokbase.com/t/r/r-help/137hry3mga/r-writing-multiple-lines-to-a-file



也可以用水槽

水槽(“tmp_out.txt”)   con  & lt;作用;文件(“raw.txt”,“r”)   line  & lt;作用;readline (con, n=1)   而(长度(线),!=,0),{   ,,c =, unlist (strsplit(线,,“\ t”))   ,,if  (c[1],==,“叠连群”),{   ,,,,,,,,,# k_test  & lt;作用;rbind (k_test, c)   ,,,,,,,,,猫(线)   ,,,,,,,,,猫(“\ n”)   ,,}   ,,else  if  (as.numeric (c [1]), %, %, g.out美元名称),{,   ,,,,,,,,# # a  & lt;作用;酸式焦磷酸钠(c, as.numeric)   ,,,,,,,,# # k_test  & lt;作用;rbind (k_test,,)   ,,,,,,,,猫(线)   ,,,,,,,,猫(“\ n”)   ,,}   ,,line =, readline (con, n=1)   }   关上(con)   水槽()


R语言字符串写入文件