【问题标题】:R shiny module: call reactive data from parent serverR闪亮模块:从父服务器调用反应数据
【发布时间】:2018-01-10 02:14:03
【问题描述】:

我正在尝试使用来自模块外部的反应数据调用 R 闪亮模块,我阅读了教程并知道 '()' 不应该包含在反应数据的 callModule 参数中。但是我收到一条错误消息: Warning: Error in as.vector: cannot coerce type 'closure' to vector of type 'list 之后。

这是模块的代码:

pieTableUI <- function(id, header, titleInfo, width = 6) {

ns <- NS(id)

infoClick <- h3(header,
              tipify(
                el = icon("info-circle"), trigger = "hover click",
                title = titleInfo
              ))

tagList(
tabBox(
  tabPanel("Pie Chart",
           infoClick,
           htmlOutput(ns("piechart"))),
  tabPanel("Table",
           infoClick,
           htmlOutput(ns("table"))),
  width = width
    )
  )
}

pieTable   <- function(input, output, session, dataChart, x, y) {

 output$piechart <- renderGvis({
 gvisPieChart_HCSC(dataChart, x, y)
 })

output$table    <- renderGvis({
gvisTable(dataChart)
})

}

我调用了这个模块:

callModule(pieTable, "agegroupplot", dataChart = agegroup_data, x = "AGE_GROUP_CLEAN", y = "n")

agegroup_data 是来自服务器的响应式数据帧。

【问题讨论】:

    标签: r module shiny


    【解决方案1】:

    我认为问题在于您没有在pieTable 函数的主体中的dataChart 之后添加括号。要获取反应式表达式的值,必须调用它,类似于函数。

    pieTable   <- function(input, output, session, dataChart, x, y) {
    
      output$piechart <- renderGvis({
          gvisPieChart_HCSC(dataChart(), x, y) 
      })
    
      output$table    <- renderGvis({
         gvisTable(dataChart())
      })
    
    }
    

    【讨论】:

      猜你喜欢
      • 2020-03-12
      • 1970-01-01
      • 2016-08-10
      • 2020-05-17
      • 2015-06-22
      • 2017-12-09
      • 2019-09-01
      • 2021-05-08
      • 2018-03-17
      相关资源
      最近更新 更多