Reputation: 495
I am new to Shiny and would like to know how would I open / display a new form after selecting an option.
In the example below, if I select Upload, then I would like to open / display a form that would let me upload the data and if I select Analyze Data then it would let me open / display a form that would let me Analyze Data.
Any advice / help would be appreciated.
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
selectInput(inputId = "Task", label = "Select Task",choices = c("Please select","Upload","Analyze Data")),
textOutput("SR_Text")
)
# Define server logic required to draw a histogram
server <- function(input, output) {
observeEvent(input$Task, {
if(input$Task == "Upload"){
output$SR_Text<-renderText({
"Upload"
})
} else if (input$Task == "Analyze Data"){
output$SR_Text<-renderText({
"Analyze Data"
})
}
})
}
# Run the application
shinyApp(ui = ui, server = server)
Upvotes: 0
Views: 386
Reputation: 29407
I think conditionalPanel
is all you need:
library(shiny)
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
column(3,
selectInput("Task", label = "Select Task",choices = c("Please select","Upload","Analyze Data"))
),
column(9,
conditionalPanel(
condition = "input.Task == 'Upload'",
fileInput("Upload", h3("File input Upload")),
selectInput(
"breaks", "Breaks",
c("Sturges",
"Scott",
"Freedman-Diaconis",
"[Custom]" = "custom")),
),
conditionalPanel(
condition = "input.Task == 'Analyze Data'",
sliderInput("breakCount", "Break Count", min=1, max=1000, value=10)
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output,session) {
}
# Run the application
shinyApp(ui = ui, server = server)
Upvotes: 1