John
2019-May-06 02:24 UTC
[R] The function sink() --delete everything before printing by "sink()"
I use the functions "sink" and "print" to print the results to a txt file. May I delete everything in the txt files before it start to print to the txt file? Thanks! ####### sink(file_output.txt")) for(i in c("a", "b")) { for(j in c("c", "d")) { { print(c(i,j)) print(xyz1[[i,j]]) print("t-stat") print(abc1[[i,j]]) } } } sink() ######### [[alternative HTML version deleted]]
Eric Berger
2019-May-06 08:02 UTC
[R] The function sink() --delete everything before printing by "sink()"
?sink for the HELP page on that sink() function. Check the description of the (optional) argument append to get an answer to your question. On Mon, May 6, 2019 at 5:24 AM John <miaojpm at gmail.com> wrote:> I use the functions "sink" and "print" to print the results to a txt file. > May I delete everything in the txt files before it start to print to the > txt file? Thanks! > ####### > sink(file_output.txt")) > for(i in c("a", "b")) > { > for(j in c("c", "d")) > { > { > print(c(i,j)) > print(xyz1[[i,j]]) > print("t-stat") > print(abc1[[i,j]]) > } > } > } > sink() > ######### > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]