2017-08-02 117 views
0

我想从模块外部调用R闪亮模块与反应数据,我阅读教程,并知道'()'不应包含在callModule参数中数据。不过,我收到了一条错误消息: Warning: Error in as.vector: cannot coerce type 'closure' to vector of type 'list之后。R闪亮模块:从父服务器调用反应数据

下面是模块的代码:

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是来自服务器的数据框反应。

回答

1

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

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

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

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

} 
相关问题