0

I have one folder with 2 Shiny apps inside - they share ui.R and server.R but their global.R files differ. How to run Shiny app with global2.R file instead of global.R? I was trying

shiny::shinyApp(
  ui = source("ui.R")$value, 
  server = source("server.R")$value, 
  onStart = source("global2.R")
)

but it doesn't work. Not sure if relevant but I'm publishing the app on RStudo Connect.

mihagazvoda
  • 1,057
  • 13
  • 23
  • For me, this sounds like you have just one shiny app with two different databases. Whats in your `gloabl2.R`? – danlooo May 17 '22 at 07:18
  • It's a bit hackish. Apps have 1 feature different (this is a boolean variable in global.R). But I need 2 dashboards since they are for 2 different groups of people. – mihagazvoda May 17 '22 at 07:22
  • 1
    I would use environmental variables and spin two docker containers with the same image containing ui and server instead. You can also just create a file `state.txt` containing either TRUE or FALSE and then do `state <- readLines("state.txt")` in the common global.R. – danlooo May 17 '22 at 07:29
  • ...or even pick up the user's name (`Sys.info()["user"]`?) and decide on the appropriate UI using a lookup table... It would also be easy to include a button/menu item to allow users to flip between the two UIs (if that is an appropriate thing to do). – Limey May 17 '22 at 07:31
  • We are using RStudio Connect to deploy our apps so I don't think this is the option. – mihagazvoda May 17 '22 at 07:42

0 Answers0