Temporary data input/output

There are three levels of scoping within the temporary, portable part of a Shiny application:

  • The lowest level is data that is read-only within each individual instance of a Shiny application. This level is quite useful if a user wants a fresh copy of data each time they visit the application (if data needs to be even fresher than this, it can be placed in a reactive function). Any data loaded after the shinyServer() function will be scoped like this. Note that this data is only available from the server.R file and not from the ui.R file, which is loaded first.
  • The next level up is data that is available to all instances of the application (again, just within server.R). This can be useful if there is a very large dataset that needs to be loaded or that needs significant processing; this can then be done the first time the application spins up, so users do not have to wait for it. Any data loaded before the shinyServer() function will be scoped in this way.
  • Lastly, it is possible to make data available to ui.R and server.R across all functions by loading it in a file called global.R. It isn't very often that you would want to do this; I never have, but you may find it useful if you wish to configure your UI using data but don't want or need the extra code and processing time a dynamic UI would necessitate.

Remember that it is very easy to get data in and out of Shiny sessions (that is, temporarily) using the fileInput() and downloadHandler() functions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset