This maybe a general question and I will try my best to describe it explicitly. In R Shiny and the ui.R
file, I use radioButtons
to select one of the two methods:
radioButtons("Methods", strong("Choose a Method:"),
choices = list("method_1" = "m1",
"method_2" = "m2"),
selected="method_1"),
selectInput("method_2_ID", strong("Choose an ID (method_2"),
topIDs)
mainPanel(
tabsetPanel(
tabPanel(title = "method_1_tab1",
plotOutput("plots"),
tabPanel(title = "method_2_output1",
tableOutput("m2_output1")),
tabPanel(title = "method_2_output2",
verbatimTextOutput("m2_output2")))
))
You can see for method_2, I plan to use two different tabs to show different results, i.e. m2_output1
and m2_output2
. In my server.R
file, I use:
if (input$Methods == "method_2") {
# m2_output1
updateTabsetPanel(session, "method_2_output1", selected="panel2")
# drop-down menu
SelectedID = reactive(function(){
input$method_2_ID
})
# m2_output1
output$m2_output1 = renderTable({
m2[m2$ID == input$method_2_ID, ]
})
# m2_output2
updateTabsetPanel(session, "method_2_output2", selected="panel3")
[...]
output$m2_output2 = renderPrint({
[...]
}
})
However, it works only for the method_2_output1
tab when I click the ID from the drop-down menu, and when I click the method_2_ouptut2
tab, there is nothing displayed (should display verbatimTextOutput("m2_output2)"
, I think). Is there anything wrong with my ui.R
or server.R
files?