我用不同的模块和文件开发了一个闪亮的应用程序,我的updateTabsetPanel有一些问题:一个主文件,其中每个选项卡项目都是不同文件中的不同模块。我让模块浏览和注释,它们的调用方式如下:
#### in the main app
server <- function(input,output,session){
ns <- session$ns
## Sidebar panel for inputs
output$menu <- renderMenu({
sidebarMenu(id = "tabs_menu",
menuItem("Input data",tabName ="datafile", icon = icon("file-import")),
menuItem("Explore", tabName = "explore", icon = icon("microscope")),
menuItem("Annotate", tabName = "annotate", icon = icon("edit")),
menuItem("Clusters", tabName = "cluster", icon = icon("asterisk"))
)})
global_data <- callModule(Module_input_data_server, "data_module" )
#Module explore
observeEvent(input$tabs_menu,{
if(input$tabs_menu=="explore"){
callModule(Module_explore_server, "explore_module", global_data )
}
}, ignoreNULL = TRUE, ignoreInit = TRUE)
#Module annotate
observeEvent(input$tabs_menu,{
if(input$tabs_menu=="annotate"){
callModule(Module_annotate_server, "annotate_module",global_data)
}
}, ignoreNULL = TRUE, ignoreInit = TRUE)
}在explore模块中,我有不同的模块,其中一个是我希望在单击按钮后返回的表,感谢模块annotate。因此,目标是在单击操作按钮后返回到探索。但它不起作用。
#### in the annotate module the observe event for the click button
Module_annotate_server <- function(input, output,session, rv) {
req(rv$data)
ns <- session$ns
observeEvent(input$annotateButton,{
req(rv$data)
print("how")
# if(is.null(rv$secure)){
if(!is.null(input$newCol) && input$newCol != "") {
print("how1")
new.column <- rep(NA,nrow(rv$data))
rv$data <- cbind(rv$data, new.column)
colnames(rv$data)[ncol(rv$data)] <- input$newCol
rv$annotationCol <- input$newCol
} else if(!is.null(input$annotationCol) && input$annotationCol != "") {
print("how2")
rv$annotationLabels <- unique(rv$data[,input$annotationCol])
rv$annotationCol <- input$annotationCol
}
if(length(input$labelsList)>0) {
print("how3")
new.labels <- unlist(strsplit(input$labelsList, "\\s*,\\s*"))
if(length(new.labels)>0) {
rv$annotationLabels <- c(input$annotationLabels, new.labels)
}
}
if(is.null(rv$annotationLabels) || length(rv$annotationLabels) == 0) {
showNotification("Some labels must be provided.", type ="error", duration = NULL)
} else {
# Move to the Explore tab
updateTabsetPanel(session , "tabs_menu", selected = "explore")
}
}我想知道是什么问题,可能是会议或其他事情,如果你有想法。
谢谢!
发布于 2020-06-23 21:56:34
您的module_annotate_server没有返回值。这就是它不返回任何东西的原因。您需要在包含要返回的数据的模块中创建一个反应式,然后在模块的服务器函数的末尾返回反应式的名称。如下所示:
returnValue <- reactive({
.... some code here ....
})
return(returnValue)另外,不要把你的callModule放在reactives里面。这就是灾难的秘诀。只需将它们放在主服务器函数的主体中:
exploreVal <- callModule(Module_explore_server, "explore_module", global_data )然后,您可以使用exploreVal()引用模块的返回值。对你的annotate_module做类似的事情。
https://stackoverflow.com/questions/62535986
复制相似问题