withSink | R Documentation |
Execute an expression while redirecting output to a file
withSink(expr, logfile = tempfile(fileext = ".txt"))
expr |
The expression to execute |
logfile |
The file to redirect output to. Default is "tmp.txt". |
The result of the expression
logfile <- tempfile(fileext = ".txt")
withSink(logfile = logfile, expr = {
cat("Helloworld\n")
message("Goodbye")
})
readLines(logfile) == c("Helloworld", "Goodbye")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.