[Rd] Warnings created during R_eval or R_tryEval not shown before R ending or R error.

Laurent Gautier |g@ut|er @end|ng |rom gm@||@com
Sat Apr 29 22:16:07 CEST 2023


Thanks Ivan. I did not know about ` .Internal(printDeferredWarnings())`. It
does provide a solution for what I need.
Best,
Laurent

Le mer. 26 avr. 2023 à 06:23, Ivan Krylov <krylov.r00t using gmail.com> a écrit :

> В Sun, 23 Apr 2023 13:33:16 -0400
> Laurent Gautier <lgautier using gmail.com> пишет:
>
> > When tracing what happens during an error I found that
> > verrorcall_dflt() in src/main/errors.c calls PrintWarnings(). That
> > function is not part of R's C-API though.
>
> I've tried reading the source code and came to a similar conclusion.
>
> PrintWarnings() is required for warnings() to work because it creates
> the last.warning variable for warnings() to access. When driving an
> embedded R, R_ReplDLLdo1() will call it for you between expressions it
> processes, but there doesn't seem to be a way to call it yourself.
>
> Interestingly, there is .Internal(printDeferredWarnings()) which
> eventually calls PrintWarnings(), but it's not exported as an API, only
> used in a few places like try().
>
> Would it help to run with options(warn = 1)? I think that a different
> code path is taken in this case, which should emit warnings even
> without a working REPL. warnings() would still be empty, unfortunately.
>
> --
> Best regards,
> Ivan
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list