2

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'

Kabau
  • 79
  • 2
  • 8

1 Answers1

4

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.

Community
  • 1
  • 1
nrussell
  • 18,382
  • 4
  • 47
  • 60
  • Thank-you for this explanation, it worked and it's helped my understanding of it. Simply adding the () into where I was trying to reference it worked perfectly. Thank-you for your help. – Kabau Jul 16 '14 at 12:16