updateTabsetPanelが動かない。
Shinyに関する質問です。
検索条件を入れて、検索してその結果が得た場合、tabをデータ表示のtableに切り替えて表示したい。
しかし、updateTabsetPanelは動かない。
なにか問題か教えてほしいです。
Server.Rから
shinyServer(function(input, output) {
callModule(tab_search,id = "tab_search")
})
ここは作成されたモジュールです。
################################################################################
#the layout for tab search item
#Parameter: p_shipment
# p_product
tab_searchUI <- function(id, tab_name,p_shipment,p_product,p_duration) {
ns <- NS(id)
tabItem(tabName = tab_name,
sidebarLayout(
sidebarPanel(
#Set the search condition here.
#The first search key is duration.
dateRangeInput(inputId = ns("i_dates"), label = "Duration"),
#The second search key is shipments
selectizeInput(
inputId = ns("i_shipment"), label = "Shipment", choices = state.name, multiple = TRUE
),
#The third search key is data products
selectizeInput(
inputId = ns("i_product"), label = "Product", choices = state.name, multiple = TRUE
),
#The search button
actionButton(inputId = ns("b_srh"),label = "Search")
),
#Output the search result.
mainPanel(
tabsetPanel(type = "tabs",
id = ns("srh_tabs"),
tabPanel("Search",
h2("Search result is shown here.",align = "center"),
br(),
div(img(src="bigorb.png"),align="center")),
tabPanel("Table", tableOutput(ns("table"))),
tabPanel("Summary", verbatimTextOutput(ns("summary"))),
tabPanel("Plot", plotOutput(ns("plot")))
)
)
)
)
}
################################################################################
#Server side corresponding the tab of tab_searchUI
#Notice the function name is paired with corresponding UI
#
tab_search<- function(input, output, session){
srhresult <- NULL
ltabs <- NULL
stab <- NULL
# the case to use eventreactive function for getting the event of a button.
reactive_data <- eventReactive(input$b_srh, {
#Set the search result
ltabs <- session$ns("srh_tabs")
stab <- session$ns("table")
print(paste("tabset name is ", ltabs," >>"))
print(paste("tab name is ", stab," >>"))
g_Search_rlt <<- srhresult
srhresult <- pistonrings
})
output$table <- renderTable(reactive_data())
#Change the tab to table
observeEvent(input$b_srh, {
print(session$ns("srh_tabs"))
print(session$ns("table"))
updateTabsetPanel(session, paste(session$ns("srh_tabs")),
selected = paste(session$ns("table"))
)
# output$caption <- renderText(paste(l_caption(),"case 2"))
})
}