r闪亮的模块,从服务器返回的反应性表达未知
在我的“主应用程序”中,我想通过随附的闪亮模块来处理返回的的反应剂。我的问题是我找不到一种“抓住”返回反应性的方法。
当我尝试解决反应性时,会有一个错误消息: 警告:recturn_data中的错误:找不到函数“ reded_data”
是否有任何方法可以做到这一点?
require(shiny)
example_UI <- function(p_id) {
actionButton(NS(p_id,"mergelist"), "mergelist")
}
example_Server <- function(p_id, p_list) {
moduleServer(p_id, function(input, output, session) {
observeEvent(input$mergelist, {
return(reactive({
rbind(data.frame("ID" = c(3, 5), "NAME" = c("lorem", "ipsum")), p_list())
}))
})
})
}
example_App <- function() {
global_list <- reactiveVal({ data.frame(ID = integer(), NAME = character()) })
ui <- fluidPage(
example_UI(p_id = "example"),
verbatimTextOutput("rows")
)
server <- function(input, output, session) {
returned_data <- example_Server(p_id = "example", p_list = global_list)
output$rows <- renderText({
nrow(returned_data())
})
}
shinyApp(ui, server)
}
runApp(example_App())
In my "master app" i want to handle the reactives that are returned by included shiny modules. My problem is that I don't find a way to "catch" the returned reactive.
There is an error message when i try to resolve the reactive: Warning: Error in returned_data: could not find function "returned_data"
Is there any way to do this?
require(shiny)
example_UI <- function(p_id) {
actionButton(NS(p_id,"mergelist"), "mergelist")
}
example_Server <- function(p_id, p_list) {
moduleServer(p_id, function(input, output, session) {
observeEvent(input$mergelist, {
return(reactive({
rbind(data.frame("ID" = c(3, 5), "NAME" = c("lorem", "ipsum")), p_list())
}))
})
})
}
example_App <- function() {
global_list <- reactiveVal({ data.frame(ID = integer(), NAME = character()) })
ui <- fluidPage(
example_UI(p_id = "example"),
verbatimTextOutput("rows")
)
server <- function(input, output, session) {
returned_data <- example_Server(p_id = "example", p_list = global_list)
output$rows <- renderText({
nrow(returned_data())
})
}
shinyApp(ui, server)
}
runApp(example_App())
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
多亏了@limey,我发现了自己的错误,并能够解决问题。
Thanks to @Limey I found my mistake and was able to solve the problem.