Suppress error message in R

Inga

I am running a simulation study in R. Occassionally, my simulation study produces an error message. As I implemented my simulation study in a function, the simulation stops when this error message occurs. I know that it is bad practice to suppress errors, but at this moment to me there is no other option than to suppress the error and then go on with the next simulation until the total number of simulations I like to run. To do this, I have to suppress the error message R produces.

To do this, I tried different things:

library(base64)
suppressWarnings
suppressMessages
options(error = expression(NULL))

In the first two options, only warnings and message are suprressed, so that's no help. If I understand it correctly, in the last case, all error messages should be avoided. However, that does not help, the function still stops with an error message.

Has someone any idea why this does not work the way I expect it to work? I searched the internet for solutions, but could only find the above mentioned ways. In the function I am running my simulation, a part of the code is analysed by the external program JAGS (Gibbs sampler) and the error message is produced by this analysis. Might this be where it goes wrong?

Note that I do not have to supress a certain/specific error message, as there are no other error messages produced, it is 'good enough' to have an option that supresses just all error messages.

Thanks for your time and help!

Carl Witthoft

There is a big difference between suppressing a message and suppressing the response to an error. If a function cannot complete its task, it will of necessity return an error (although some functions have a command-line argument to take some other action in case of error). What you need, as Zoonekynd suggested, is to use try or trycatch to "encapsulate" the error so that your main program flow can continue even when the function fails.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Suppress error message in R

From Dev

tryCatch suppress error message

From Dev

How to suppress error message of a command?

From Dev

How to suppress OpenCV error message

From Dev

matlab - suppress error message backtrace

From Dev

How to suppress R startup message?

From Dev

Suppress supplementary error message from unit test

From Dev

JAX-RS : Suppress Error Message

From Dev

Not able to suppress the error message using /dev/null

From Dev

How to suppress certain error message in 'find' command?

From Dev

Suppress system error with trycatch in R

From Dev

Suppress convergence message in nnet multinom function in R

From Dev

Forms Suppress Error Message And Catch frm-40350

From Dev

Numpy / Polyfit - Suppress printing of Intel MKL Error message

From Dev

Forms Suppress Error Message And Catch frm-40350

From Dev

Numpy / Polyfit - Suppress printing of Intel MKL Error message

From Dev

Can i suppress error message from fetch.pm in Perl

From Dev

How to suppress PowerShell error message during variable assignment

From Dev

Suppress "Error during loading" message in standalone Jasmine 3.1 browser report

From Dev

How to suppress download.file() "trying URL..." message in R?

From Dev

Suppress Message Box R6025 Pure Virtual Function Call

From Dev

How to suppress warning message in R regarding closing unused connection?

From Dev

How to suppress the warming message by R when using commandArgs()

From Dev

Suppress library message output

From Dev

Suppress server message in rsync

From Dev

How to suppress the error message when dividing 0 by 0 using np.divide (alongside other floats)?

From Dev

Suppress specific MySQL warning message

From Dev

Interpreting error message in regression in R

From Dev

R Metrics auc() error message

Related Related

  1. 1

    Suppress error message in R

  2. 2

    tryCatch suppress error message

  3. 3

    How to suppress error message of a command?

  4. 4

    How to suppress OpenCV error message

  5. 5

    matlab - suppress error message backtrace

  6. 6

    How to suppress R startup message?

  7. 7

    Suppress supplementary error message from unit test

  8. 8

    JAX-RS : Suppress Error Message

  9. 9

    Not able to suppress the error message using /dev/null

  10. 10

    How to suppress certain error message in 'find' command?

  11. 11

    Suppress system error with trycatch in R

  12. 12

    Suppress convergence message in nnet multinom function in R

  13. 13

    Forms Suppress Error Message And Catch frm-40350

  14. 14

    Numpy / Polyfit - Suppress printing of Intel MKL Error message

  15. 15

    Forms Suppress Error Message And Catch frm-40350

  16. 16

    Numpy / Polyfit - Suppress printing of Intel MKL Error message

  17. 17

    Can i suppress error message from fetch.pm in Perl

  18. 18

    How to suppress PowerShell error message during variable assignment

  19. 19

    Suppress "Error during loading" message in standalone Jasmine 3.1 browser report

  20. 20

    How to suppress download.file() "trying URL..." message in R?

  21. 21

    Suppress Message Box R6025 Pure Virtual Function Call

  22. 22

    How to suppress warning message in R regarding closing unused connection?

  23. 23

    How to suppress the warming message by R when using commandArgs()

  24. 24

    Suppress library message output

  25. 25

    Suppress server message in rsync

  26. 26

    How to suppress the error message when dividing 0 by 0 using np.divide (alongside other floats)?

  27. 27

    Suppress specific MySQL warning message

  28. 28

    Interpreting error message in regression in R

  29. 29

    R Metrics auc() error message

HotTag

Archive