How to change warning setting?

前端 未结 3 1387
醉话见心
醉话见心 2020-12-28 17:25

I am trying to debug a function. I would like to display warnings when they occur but I don\'t understand how to change the warning settings.

3条回答
  •  北海茫月
    2020-12-28 18:01

    From the help page for options :

    warn: sets the handling of warning messages. If warn is negative all warnings are ignored. If warn is zero (the default) warnings are stored until the top–level function returns. If fewer than 10 warnings were signalled they will be printed otherwise a message saying how many (max 50) were signalled. An object called last.warning is created and can be printed through the function warnings. If warn is one, warnings are printed as they occur. If warn is two or larger all warnings are turned into errors.

    So options(warn=1) should print warnings as they occur.

    Otherwise function traceback() (after an unidentified error) shows you which subroutine failed (more exactly "the sequence of calls that lead to the error").

提交回复
热议问题