[R] Redirecting Messages and Errors to a file

From: McGehee, Robert <Robert.McGehee_at_geodecapital.com>
Date: Thu 28 Jul 2005 - 00:30:58 EST


Hello all,
I'm trying to setup a simple construct that will email me all errors, warnings, and 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.

Any thoughts on how to do this such that everything is sent to the file for emailing? Perhaps something different all together?

Thanks,
Robert

This e-mail, and any attachments hereto, are intended for us...{{dropped}}



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 28 00:36:07 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:34:05 EST