2

I would like to know if it is possible to write code outside the ui and serve functions of a shiny app ?

I have a big script which involves several functions, so I would like to preserve the general structure of the pipeline when coding the shinyApp. These functions would take reactive values as parameters.

Thanks.

Micawber
  • 707
  • 1
  • 5
  • 19
  • 1
    Yes it is. You can just place them outside of the functions in the same script. – troh Apr 11 '17 at 19:48
  • All right, so that's not the reason my app doesn't work. Thank you :) – Micawber Apr 11 '17 at 19:55
  • If you are actually having trouble with code, it's best to include a minimal [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) that makes it clear what's going on. This question right now it a bit too vague to be useful. – MrFlick Apr 11 '17 at 20:16

1 Answers1

0

As stated in the comment for your question: the code in the app.R file can be placed outside the server/ui functions and will be accessible by the shiny application.

You could read more in Scoping rules for Shiny apps article, headlines:

  • All objects created outside server/ui functions is shared across all users sessions (within the same R process)
  • Objects created in server function are accessible only for current session
Marek
  • 49,472
  • 15
  • 99
  • 121