2014-03-31 157 views
0

任何人都可以帮助我如何格式化文本文件,如下图中的格式? 我正在使用R 2.12.2,因此无法使用更高版本的功能。R:格式化文本文件输出

我一直在使用writeLinesprintfcapture.output,尝试,但没有它的工作原理.. :(

f_output <- file("sample.txt") 
writeLines("D8060WK2LA MET1_PAT__ mpy Trend [5300 2450 2050]\n",f_output) 
capture.output(summary(lm_out),file="sample.txt",append=T) 
capture.output(anova_out,file="sample.txt",append=T) 
close(f_output) 

enter image description here

回答

1

我会建议尝试sink,如:

sink('sample.txt') # open sink 
# run all of your code 
sink() # close sink 

你应该得到你想要的东西

+0

非常感谢托马斯。^_ ^ – Ianthe