title: Restart shiny app from within app (reloading data)
body: <p>I want to restart a shiny app from within the app, so that e.g. code in global.R will be executed again (to reload a csv file with data). Here is a minimal example showing what I want to do:</p>
  
  <p>This shiny app loads some coordinates data and plots markers on a map. When a new marker is added to the map, the new coordinates should be appended to the old data and saved as a csv file. Then the app should restart, load data.csv again, so all markers are shown on the map. I tried adapting code from here: <a href="https://stackoverflow.com/questions/25062422/restart-shiny-session">Restart Shiny Session</a> but this doesn't work. The app restarts, but it doesn't reload the csv file.</p>
  
  <pre><code>library(shinyjs)
  library(leaflet)
  library(leaflet.extras)
  
  jsResetCode &lt;- "shinyjs.reset = function() {history.go(0)}"
  
  # data &lt;- data.frame(latitude = 49, longitude = 13)
  data &lt;- read.csv2("data.csv") # this should get executed whenever js$reset is called
  
  ui &lt;- fluidPage(
    useShinyjs(),                     
    extendShinyjs(text = jsResetCode),
      leafletOutput("map")
  )
  
  server &lt;- function(input, output, session){
    output$map &lt;- renderLeaflet({
      leaflet(data) %&gt;% addTiles()  %&gt;%
        setView(11.5, 48, 7) %&gt;%
        addDrawToolbar() %&gt;% 
        addMarkers()
    })
  
    data_reactive &lt;- reactiveValues(new_data = data)
  
    # add new point to existing data and save data as data.csv
    # after that the app should restart
    observeEvent(input$map_draw_new_feature, {
      data_reactive$new_data &lt;- rbind(rep(NA, ncol(data)), data_reactive$new_data)
      data_reactive$new_data$longitude[1] &lt;- input$map_draw_new_feature$geometry$coordinates[[1]]
      data_reactive$new_data$latitude[1] &lt;- input$map_draw_new_feature$geometry$coordinates[[2]]
      write.csv2(data_reactive$new_data, "data.csv", row.names = FALSE)
      js$reset() # this should restart the app
    })
  }
  
  shinyApp(ui, server)
  </code></pre>