Displaying 1 result from an estimated 1 matches for "mailoutput".
Did you mean:
magicoutput
2005 Jul 27
2
Redirecting Messages and Errors to a file
...output of a sample R script. My initial thought was to use
sink() and tryCatch around the script such that at the end of the script
any output would be mailed to me, i.e.:
sinkFile <- tempfile()
sink(sinkFile)
tryCatch({
[R script]},
finally = {
sink()
if (length(readLines(sinkFile)))
mailOutput(readLines(sinkFile))
})
However, the sink() does not seem to be capturing the error messages as
I would have hoped. That is, if the R-script is {print("abc");
stop("def")}, the print output is captured to the file, the stop error
message is not, and instead sent to the screen....