R-Lum/Luminescence

calc_MinDose() ... stop flooding the terminal with warnings (rmarkdown code chunk)

Closed this issue · 8 comments

Expected behaviour

Result output without none needed and confusing warning messages if run as rmarkdown code chunk.

Observed behaviour

If the function is run within a rmarkdown code chunk, the terminal is flooded with warnings.

NaNs producedNA/NaN function evaluationNA/NaN function evaluationNaNs producednumber of items to replace is not a multiple of replacement lengthNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNA/NaN function evaluationNA/NaN function evaluationNA/NaN function evaluationNA/NaN function evaluationNA/NaN function evaluationNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNA/NaN function evaluationNA/NaN function evaluation

Running mini example

Run the example below as rmarkdown code chunk.

library(Luminescence)
data(ExampleData.DeValues, envir = environment())
calc_MinDose(ExampleData.DeValues$CA1, sigmab = 0.2)

Reason?

Please check code line 423–424:

 if (!debug)
    options(warn = -1)

This option should globally switch of all warnings if debug is FALSE (the default). However, for whatever reason, it does not work in a rmarkdown code chunk. Probably the problem is not coming from the function itself, however, this behaviour is not wanted. Globally disabling warnings is a not a good idea, it prevents the discovery of changed function behaviour if debug is not set to TRUE.

tzerk commented

That's a funny one. As it so happens, I just stumbled across the very same issue. Thanks for pinpointing the issue, will have a look at it.

I think it's a knitr problem showing the console output, because knitting the file (including your chunk) will not produce any warnings in the final document. When including debug = TRUE all expected warnings are implemented in the final document.

I am afraid to say that this is not correct, the warnings are included (at least) in the HTML-file, using the following yaml-header (otherwise I would not mind).

output: 
  html_notebook

Maybe it is not an issue on Ubuntu?

Using html_document gives no warnings. using html_notebook you are right!

tzerk commented

Whatever the exact reason may be, I agree that globally disabling warning messages is not a good idea. I removed the options(warn = -1) call and will use suppressWarnings() to certain function calls. The problem is to identify them all, as mle* and all related functions are really... verbose.

tzerk commented

The minimal example doesn't produce any warning messages anymore in rmarkdown documents. I reckon you (@RLumSK ) have a more elaborate example that you could use to check if everythings fine now?

My mistake, please see comments by @JohannesFriedrich above, it seems to appear only for html_notebook.

(I'll check the new code)

Looks good to me. Please add news and close the issue.