This is a simple utility function to direct the output of stdout and stderr
to a file. stdout is the information normally printed in the console, for instance
the results of
print(rnorm(5)). stderr is the output created by functions
stop. The purpose of this function is to allow
one to direct all this output into a single file where the results can be studied, for
instance, for troubleshooting purposes. Works exactly like the base
you have to call it a second time with no arguments to close the file.
Character. A path to a filename where the results will be captured.
1 2 3 4 5 6 7 8 9 10 11 12 13
## Not run: tf <- tempfile(pattern = "SinkDemo", fileext = "txt") sinkall(tf) print("Hello") print(rnorm(2)) print(normr(2)) # typo, so it errors message("A message from message()") warning("A warning from warning()") cat("Information via cat\\n") sinkall() # one must close the file connection file.show(tf) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.