I'm working on a Shiny app to process files. If the chosen file is an R file, I need to ask an additional question, so I am attempting to include a conditionalPanel.
I'm still a bit of a noob in shiny, but with quite a bit of googling, I'm still not able to get this to work.
The selectInput("Rver",...
panel is showing up no matter what (before I've even chosen the file.
(Interestingly, the second conditionalPanel doesn't work correctly in the script below, but DOES work fine if I comment out the first conditionalPanel -- the one I'm having trouble with. So I /think/ that one is set up correctly, but please let me know if that's not the case.)
Anyway, here is what I have. Any help is greatly appreciated.
ui <- fluidPage(
titlePanel("Generate .bat file"),
div(HTML("<br>")),
fileInput("script",
"Select R or py script to automate",
accept = c(".r", ".R", ".py", "PY", "Py")),
conditionalPanel(condition = "input.script.name.indexOf(\".R\") != -1",
selectInput("Rver",
"Select R version",
choices = Rvers)),
checkboxInput("box", "Does this script connect to Box?"),
conditionalPanel(condition = "input.box == 1",
fileInput("boxToken",
"Select Box token to use",
accept = c(".json", "JSON", "Json"))),
actionButton("go", "Generate .bat file"),
div(HTML("<hr>")),
uiOutput("template")
)
server <- function(input, output){
observeEvent(input$go, {
output$template <- renderText ({
print(input$template$name)
}) #END output$template
}) #END observeEvent
}
shinyApp(ui = ui, server = server)
ps I do realize if this worked, it would only look for ".R" (but not ".r"). I'm trying to keep it as simple as I can for now.
Thanks! Luke