Reputation: 10956
I got my analysis results in R (an object called obj
) and save it as an .RData file obj-result.RData
. Now in Shiny, at the beginning of the ui.R
file, I put load("obj-results.RData")
so that each time Shiny is run, this object can be loaded into R session, i.e. I expect that the obj
object would be available to use in subsequent steps, such as obj@data
, obj@sample
, etc.
However, I find that load
won't make the obj
object available in current R session, so that Shiny could not find the quantities required. Is there anything I missed in loading the .RData object? Thank you so much!
Upvotes: 4
Views: 3605
Reputation: 287
I also load a .RData
file in my deployed ShinyApp ; my app works from this file. I also had difficulties to understand how the loading worked.
In this example here the statement load(...)
is located in the server.R
. This manner to proceed didn't work in my ShinyApp (the app was displayed but became immediately gray) - I don't know why. The solution was only to put the load(...)
statement in a global.R
file : load("./data/obj-result.RData", envir=.GlobalEnv)
.
Upvotes: 2
Reputation: 10956
The answer is that, whenever an object is used in the ui.R
and/or server.R
, the relevant objects must be loaded in the same file. Otherwise, shiny won't know where to find the object from other files (even they're in the same directory and loaded).
Upvotes: 5