R and Shiny: Using output of a reactive function

前提是你 提交于 2019-12-11 01:08:41

问题


Currently I have a function [degtest] which is created in the shiny server, that returns a list,

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

I want this list to be accessible after the function has run so that I can use different parts of the list to be rendered separately.

 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 is my reactdata (reactdata$degdata and input$d2 is an action button.

I thought i'd be able to reference outlist$datatable but R says ' object of type 'closure' is not subsettable'


回答1:


When you are making an object reactive, you are actually making it into a sort of function (closure), so you have to use it as outlist() rather than outlist. See this similar question. It's hard to answer your question considering you did not provide a reproducible example, but I think your solution will be something like outlist()$ObjectYouAreTryingToAccess.



来源:https://stackoverflow.com/questions/24779604/r-and-shiny-using-output-of-a-reactive-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!