[R] how to clear the last error?

Duncan Murdoch murdoch at stats.uwo.ca
Thu Feb 9 19:04:50 CET 2006


On 2/9/2006 11:11 AM, Adrian Dragulescu wrote:
> Hello,
> 
> I would like to clear the last error that I get with geterrmessage().  Not
> even rm(list=ls()) clears it.  Can I set it to NULL somehow?

Not from R, but there is a C-level way to do it in src/main/errors.c. 
It's marked as "temporary", but it's been there since R 1.3.x.

The declaration is

void R_SetErrmessage(char *s);

Alternatively, you could just cover up the last error with a new one by 
calling stop, e.g.

 > try(stop(""),TRUE)
 > geterrmessage()
[1] "Error in try(stop(\"\"), TRUE) : \n"

Duncan Murdoch




More information about the R-help mailing list