Error in publishing shinyapps.io

Hi All,

I have a problem with publishing my shiny code. I have written a shiny code (server.R and ui.R). I run my code from Rstudio and it works perfectly (I can see the shiny results). It concludes dygraphs and leaflet map and so many other stuff.
I signed up in shinyapps.io to publish my result on the webpage to share it with my colleagues.
When I want to publish it, everything is fine and it builds a URL for my result, but at the end, I get an error when I open the URL. the error is:
" ERROR: An error has occurred. Check your logs or contact the app author for clarification."
But as I said, I can see the result in my own Rstudio.
Is there anybody who can help me in this regard? Does The problem come from my code? or the shinyapps.io cannot support my code?

What your app's logs say?

This has to do with your code, you are not properly referencing the source for the dygraphOutput() function which I suppose it should be the dygraphs package. Have you included the library call at the beginning of your code?.

library(dygraphs)

Yes I aware of that. The problem is that it works when I run shiny from my RStudio and I can see the results and everything is fine, which means that I called all libraries that are needed including dygraphs. But, when I publish it in shinyapps, it gives me this error.
Do you have any idea why it is happening?

Not necessarily, when run locally, the app runs on the environment you are already using which might include libraries that have been loaded interactively and not programmatically

Hard to know without seen any code or preferably a reproducible example.

I could fix that by using one app.R file instead of two server.R and ui.R files. I was calculating something and I put them somewhere wrong.
Now I got another error which is related to masking packages (the figure).
Can you help me how can I fix it?

I think those are warnings about masking packages.
The error relates to an attempt to change working directory.
Do you use setwd () in your app ? This should not be used in an app intended to be hosted by shinyapps.io

1 Like

Thank you for your help. You were right. Now it is working. You can see my code here:
https://hame.shinyapps.io/OnlineMonitoring/
I need your thoughts and opinion here to continue my work. In this code, I am using a dataset that is calculated using another R code ( load (file = "FlowResult.RData") ). To explain more, there is a website of rainfall data which is updating every one hour. I wrote a code, to read this rainfall data, run my model and give me the output (runoff flow volume at outfalls) and save it as "FlowResult.RData" that I am using here in shinyapps code. in this stage, I am running this code using my own laptop every one hour.
What I am going to do, is to I) automatically run my R code separately in a cloud or somewhere (not in my laptop), II) then get the result ("FlowResult.RData") and save it somewhere that shinyapps can read it, III) then update the shinyapps every one hour. So the readers can see the updated results.
Do you have any idea how can I do these three steps?
Is there any options in shinyapps to schedule events (run every one hour)? is there any boxes or location in shinyapps to save my "FlowResult.RData" result there?