I'm writing some text to R console using print(), cat() and message()
functions. I wish to collect console outputs into a text file, so I sandwiched the code between a pair of sink()
functions. Final code looks like:
sink("output_filename.txt")
print("some text with print function")
cat("some text with cat function")
message("some text with message function")
sink()
When I run this code, print and cat work as expected while message's output writes to console
and not output text file. Why does this happen and how do I work around this? I prefer not to replace message function with alternatives.