PatientLevelPrediction icon indicating copy to clipboard operation
PatientLevelPrediction copied to clipboard

PLP Package Conflict in R Markdown - Error in globalCallingHandlers Write

Open ElenaW0703 opened this issue 1 year ago • 2 comments

Describe the bug Hello,

I'm encountering an issue with our PLP package when used in R Markdown (Rmd). Occasionally, an error is raised stating "Error in globalCallingHandlers (condition=conditionHandler): should not be called with handlers on the stack".

Interestingly, there is no bug reporting, and the same code can be executed without any issues in the Console. This leads me to guess that the problem might be related to how the package is set up in R Markdown.

Here's a brief overview of the issue: Package: PLP Environment: R Markdown Error Message: "Error in globalCallingHandlers (condition=conditionHandler): should not be called with handlers on the stack" Observation: Same code runs without errors in the Console.

If anyone could provide assistance or insights into this issue, it would be greatly beneficial to Rmd users.

Thank you in advance for your help.

ElenaW0703 avatar Jun 29 '23 15:06 ElenaW0703

I have experienced this issue before, however, I found it not to be a big obstacle so I did not really do anything about it.

If you notice, the same code in an Rscript works fine, while it can yield an error when called within an .Rmd file; specifically, running the chunk will yield the error, whereas, as you said, if you just run the code (select the code in the chunk that yields the error and run it) it should be executed without an error.

In my case, since I was able to knit the document without any problems, I did not dig deeper into the issue. I am not sure what causes the error; either it's the tryCatch() calls or the logging which both use handlers, however I am not very familiar with handlers and how they are used. There are similar issues here and here. The problem with this error is that is not easily reproducible, but if you experienced the issue with Eunomia as your database then it would be nice to share also your script.

@ElenaW0703 is it possible that you try to knit the document (which will start a new process) and verify that you receive the same error?

solis9753 avatar Jun 29 '23 18:06 solis9753

Hey, really appreciate your thoughtful explanation and good ideas! I'll try and thank you again! :)

ElenaW0703 avatar Jun 29 '23 21:06 ElenaW0703