Other Optimisations: Data munging

As the server function is called every time a new session starts.

If you use some data that looks always the same, you should move that process outside the server function.

my_data_prep <- function() {
  df <- read.csv("path/to/file.csv")
  df %>% 
    filter(!not_important) %>% 
    group_by(my_variable) %>% 
    some_slow_function()
}

df <- my_data_prep()

server <- function(input, output, session) {
  # Lots more code
}