[R] append to all warnings

Rory Wilson roryrwilson at yahoo.ca
Tue May 5 10:48:03 CEST 2015


Hello all,This may be a "newbie" type question but I am rather stuck. I would like to alter my R options such that anytime a warning is generated, the standard warning message is generated, as well as additional details that I would specify (ie, time/date, etc.)
It seems to me something like 
myWarning <- function () {  warnings()  print(Sys.time())}
options(warn=1,warning.expression=quote(myWarning()))
could almost(!) work, but all it does it print the date, rather than the original warning message AND the date.
ie,
log(c(3,-5))

gives
[1] "2015-05-05 04:42:52 EDT"
[1] 1.098612      NaN
I am sure there is a simple solution, but I cannot find it in the help, nor by Googling.  
Thank you all for your help! Sorry if this is rather elementary.
Rory

	[[alternative HTML version deleted]]



More information about the R-help mailing list