R 显示从列表输出中提取的多个表

R 显示从列表输出中提取的多个表,r,shiny,R,Shiny,我使用一个函数返回一个n个数据帧的列表:n是变量,取决于变量的级别数 我想使用server.R中的循环来显示这n个表 这是我的密码: outlist2 <- reactive(label="toto", ({ if(is.null(input$datafile)){return()} if(is.null(input$varinteret) || is.null(input$vartemps) # ||is.nul

我使用一个函数返回一个n个数据帧的列表:n是变量,取决于变量的级别数

我想使用server.R中的循环来显示这n个表

这是我的密码:

 outlist2 <- reactive(label="toto", ({

     if(is.null(input$datafile)){return()}
     if(is.null(input$varinteret)
        || is.null(input$vartemps)
        #           ||is.null(input$apparie)
                   ||is.null(input$tempsrefouinon)
                   ||is.null(input$prodrefouinon)
        #           ||is.null(input$checkprod)
        #           ||is.null(input$checkprodref)
     )
     {return()}
     else
     {
       data<-filedata()
       res.comparer<-compareT0parproduit(data=data,y=input$varinteret,group=input$varprod,TemoinNametemps=input$checktempsref, group2 = input$vartemps)
     }  
 })) 
   # 

 nblevels<-reactiveValues(filedata()[,input$varprod])
 for (i in 1:nblevels){
    output$uicomparetempsT0(i) <- shiny::renderTable({ 
      outlist2()$res.comparer[[i]]
还有我的错误消息

Warning: Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
Stack trace (innermost first):
    44: .getReactiveEnvironment()$currentContext
    43: .dependents$register
    42: filedata
    41: reactiveValues
    40: server [C:\Users\itm\Desktop\Documents\appli Clarins test/server.R#454]
     1: shiny::runApp
Error in .getReactiveEnvironment()$currentContext() : 
  Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
好,, 我尝试了以下代码行: 受此链接启发:

观察(

outlist2 1 tableOutput只能输出1个表。不是多个。但它是一个仅一个数据表。outlist2()$res.comparer[[i]]是一个表。
Warning: Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
Stack trace (innermost first):
    44: .getReactiveEnvironment()$currentContext
    43: .dependents$register
    42: filedata
    41: reactiveValues
    40: server [C:\Users\itm\Desktop\Documents\appli Clarins test/server.R#454]
     1: shiny::runApp
Error in .getReactiveEnvironment()$currentContext() : 
  Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
   observe(  
     outlist2 <- reactive(label="toto", ({

         if(is.null(input$datafile)){return()}
         if(is.null(input$varinteret)
            && is.null(input$vartemps)
                       && is.null(input$apparie)
                       && s.null(input$tempsrefouinon)
                       &&is.null(input$prodrefouinon)
                       &&is.null(input$checkprod)
                       &&is.null(input$checkprodref)
         )
         {return()}
         else
         {
           data<-filedata()
           res.comparer<-compareT0parproduit(data=data,y=input$varinteret,group=input$varprod,TemoinNametemps=input$checktempsref, group2 = input$vartemps)
         # res.comparer<-list(data(), data())
           }  
     })) 
       # 

)


     nblevels<-reactive({
       if(is.null(input$datafile)){return()}
       if((is.null(input$varprod))&&(is.null(input$vartemps))) {return()}
       data<-filedata()
      res<-nlevels(data[,input$varprod])

     })



     output$plots <- renderUI({
       if(is.null(input$datafile)){return()}
       if((is.null(input$varprod))&&(is.null(input$vartemps))) {return()}
       #
      else {
       # table_output_list <- lapply(1:nlevels(data()[,input$varprod]), function(i) {
        table_output_list <- lapply(1:nblevels, function(i) {
         plotname <- paste("table", i)
         tableOutput(plotname)
       })

       # Convert the list to a tagList - this is necessary for the list of items
       # to display properly.
       do.call(tagList, table_output_list)
      }
        })

          for (i in 1:nblevels)
      {
       # Need local so that each item gets its own number. Without it, the value
       # of i in the renderPlot() will be the same across all instances, because
       # of when the expression is evaluated.
       local({
         my_i <- i
         plotname <- paste("table", my_i, sep="")

         output[[plotname]] <- renderTable({
           res2<-outlist2()
           res2$res.comparer[[my_i]]

         })

       })

}