I am relatively new to Shiny and am trying to create an app that creates a global variable that I can then pass to an R script. Here is an example of my Shiny App:
library(shiny)
ui <- fluidPage(
titlePanel("Hello"),
br(),
h3("Welcome"),
sidebarLayout(
sidebarPanel(
h1("Enter parameter value"),
selectInput("datamodel", "Update Data Model",
choices = c("Yes", "No"),
selected = "No")
),
mainPanel(
h1("Output")
)
))
# Define server logic
server <- function(input, output) {
observe({
Update_Data_Model <<- input$datamodel
})
source("Authentication.R")
}
# Run the application shinyApp(ui = ui, server = server)
The UI is created and I am able to create a global variable called Update_Data_Model to pass to my R script called Authentication.R, however the R script runs before I have time to enter the input variable in the UI.
Is there a way to execute the R script once the input variables have been entered in the UI?