Inconsistencies between R studio and Shiny (wrong package version?)


I have a problem with my shiny app. When I run the code, some results are inconsistent with what I get from R studio for the results from a specific package called "glmmTMB".

The code is working just fine on Rstudio but when I use the shiny app, I get an error message: "Can't calculate model's distribution-specific variance. Results are not reliable." which alter the results in Shiny. This seems to echo to a discussion (R2 for Zero Inflated Poisson Model · Issue #821 · glmmTMB/glmmTMB · GitHub) where the problem is solved by installing the development version of glmmTMB. Is it possible that Shiny is unable to find the right version of the package? And if so, is there a way to get around this problem?

Don't hesitate to ask for further information if needed.
Many thanks for your help.


When you say "fine on Rstudio" do you mean when running your Shiny app from RStudio or are you talking about an R notebook/script running the same computational code without Shiny? When you refer to "the shiny app", is that an app deployed on a server (your server? or running locally on your PC (started from a console or run from RStudio)?

Thanks for the quick reply.

When I say "Rstudio" I mean just running the R script with the same code without Shiny.
For the "Shiny app" I refer to both the app deployed on my server and when I run the code locally on my PC (results are identical in this case). I usually test the shiny app from Rstudio before deploying.

If you are using on your PC a development version of the glmmTMB library (as suggested in the thread you linked), then it is unlikely that is the problem. It is possible that the server does not support that version, but when you run the Shiny app locally (either from a terminal or from RStudio Desktop), it will use the library version installed on your PC.

One way to confirm this is to stick a line saying "print(sessionInfo())" in your Shiny code, after all libraries are loaded. Run the code without the Shiny parts (but including that line), which you say works, and then run the Shiny app locally, which you say does not work. Compare the package versions in the session information output and see if they are the same or different. If they are the same, the problem presumably lies elsewhere.