【问题标题】:R and Shiny: Using output of a reactive functionR and Shiny:使用反应函数的输出
【发布时间】:2014-09-06 21:53:08
【问题描述】:

目前我有一个在闪亮服务器中创建的函数 [degtest],它返回一个列表,

return(list(datatable=datatable, predicttable=predicttable, esttable=esttable)

我希望在函数运行后可以访问此列表,以便我可以使用列表的不同部分分别呈现。

 outlist <- reactive({
   if(is.null(input$file2)){return(NULL)}
   if(input$d2 == 0){return(NULL)}
   with(data = reactdata$degdata, degtest(reactdata$degdata[,input$selectTemp], reactdata$degdata[,input$selectPot],reactdata$degdata[,input$selectWeight], reactdata$degdata[,input$selectTime], input$Temp0))
   })

input$file2 是我的 reactdata(reactdata$degdata 和 input$d2 是一个操作按钮。

我以为我可以引用 outlist$datatable 但 R 说“'closure' 类型的对象不是子集”

【问题讨论】:

    标签: r shiny shiny-server


    【解决方案1】:

    当你创建一个对象reactive 时,你实际上是在把它变成一种函数(closure),所以你必须将它用作outlist() 而不是outlist。请参阅this 类似问题。考虑到您没有provide a reproducible example,很难回答您的问题,但我认为您的解决方案类似于outlist()$ObjectYouAreTryingToAccess

    【讨论】:

    • 感谢您的解释,它奏效了,帮助我理解了它。只需将 () 添加到我试图引用它的地方就可以了。谢谢你的帮助。
    猜你喜欢
    • 2014-05-11
    • 1970-01-01
    • 2018-06-23
    • 1970-01-01
    • 2020-10-05
    • 2019-12-17
    • 2020-09-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多