首页 > 解决方案 > 反应性闪亮对象类型闭包不可子集

问题描述

我无法弄清楚为什么我在这段代码中收到以下错误。我提前感谢任何想法。谢谢你。

警告:$ 中的错误:“闭包”类型的对象不是子集

Index_Percent <- reactive({input$IndexWeight})

TBA_Index_Data <- reactive({
  left_join(TBAData_Gathered,Index_Weights)

TBA_Index_Data$Index_Percentage[TBA_Index_Data$cusip == "Cash"] <- Index_Percent()

})

标签: rshinyreactive

解决方案


从您提供的代码来看,您似乎正试图在其内部加载一个反应函数。

正确的形式是这样的:

Index_Percent <- reactive({input$IndexWeight})

TBA_Index_Data <- reactive({
  # these variables are reactive functions? if so, you need to add () as well.
  table <- left_join(TBAData_Gathered,Index_Weights) 
  table$Index_Percentage[table$cusip == "Cash"] <- Index_Percent()
  table
})

推荐阅读