I have the following simple R code:
sink("output.txt", type=c("output", "message")) cat("Hello", append = TRUE) cat("World", append = TRUE) sink(NULL) It just writes the R console into a text file. I want to put it in an R source file (".r") and run it multiple times. I want to have the output as follows:
file.show("output.txt") Hello World Hello World If I run it two times, I now see:
Hello World It looks like it has been overwritten.
sink("output.txt", type=c("output", "message"), append=TRUE)?cat, theappendargument only matters if you're using thefileargument ofcat.