2017-08-02 116 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()) 
    }) 

} 
相關問題