sink_path <- file.path(tempdir(), "sink_all.txt")
sink_all(sink_path, {
print("some output")
warning("a warning")
message("a message")
print("some more output")
})
cat(readLines(sink_path), sep = "\n")
Run the code above in your browser using DataLab