withSink {FastRet} | R Documentation |
Execute an expression while redirecting output to a file
Description
Execute an expression while redirecting output to a file
Usage
withSink(expr, logfile = tempfile(fileext = ".txt"))
Arguments
expr |
The expression to execute |
logfile |
The file to redirect output to. Default is "tmp.txt". |
Value
The result of the expression
Examples
logfile <- tempfile(fileext = ".txt")
withSink(logfile = logfile, expr = {
cat("Helloworld\n")
message("Goodbye")
})
readLines(logfile) == c("Helloworld", "Goodbye")
[Package FastRet version 1.1.4 Index]