Optimal usage of server.R and global.R

Unlike UI.R, the core of the code in server.R and global.R does not normally differ significantly from normal R code. The mean calculations, statistical functions, and so on are obtained exactly in the same way within a Shiny application as in any other script.

However, in the context where code gets re-executed constantly, like in the Shiny applications, and where eventually a multi-concurrence of users can occur, performance becomes a key factor to avoid collapses.

For example, if the whole application is based on one data source, there is no point in loading it more than once. So, in this case, if the data load code is within a reactive expression in server.R, the data will be loaded unnecessarily again ...

Get Learning Shiny now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.