Advanced reactivity and data handling
Now that we've warmed up a bit, let's discuss loading data and reactivity in a bit more detail. The first thing to note is the different ways to load data in R and the effects each has. Data can be loaded before the shinyServer()
function, within the shinyServer()
function, or within a reactive function, which is itself defined within shinyServer()
.
Each has a different effect. Data loaded outside the shinyServer()
function will be loaded once only, whenever the Shiny server instance is launched (for more on running your own Shiny server see Chapter 7, Sharing Your Creations). When you're running programs locally, the server instance is launched every time the program is launched, so for local applications, there is no difference between this and data loaded within the shinyServer()
call.
When running on a real server, however, the server will be launched once and left running for months. As a consequence, this first method is a good place to perform very...