如何保存一个输出,以便以后在Shining R中的另一个输出中使用

如何保存一个输出,以便以后在Shining R中的另一个输出中使用,r,variables,output,assign,R,Variables,Output,Assign,我想使用shiny中两个输出的结果转换为另一个输出进行打印: 第一个输出是soq1,如下所示: output$soq我不确定,但我认为您正在寻找: reactive()或reactiveValues()。 我认为更简洁的版本应该使用reactive(),但为了更接近您的代码片段,我将使用后一个版本,并使用renderTable()函数执行数据修改 mat <- matrix(1:9, ncol = 3) ui <- fluidPage( tableOutput("ta

我想使用shiny中两个输出的结果转换为另一个输出进行打印: 第一个输出是soq1,如下所示:


output$soq我不确定,但我认为您正在寻找:
reactive()
reactiveValues()
。 我认为更简洁的版本应该使用
reactive()
,但为了更接近您的代码片段,我将使用后一个版本,并使用
renderTable()
函数执行数据修改

mat <- matrix(1:9, ncol = 3)

ui <- fluidPage(
  tableOutput("table1"),
  tableOutput("table2")
)

server <- function(input, output, session){
  global <- reactiveValues(mat = NULL)
  
  output$table1 <- renderTable({
    matNew <- mat
    # edit the table
    matNew[, 1] <- 1
    global$mat <- matNew
  })

  output$table2 <- renderTable({
    if(!is.null(global$mat)){
      return(global$mat)
    }
  })
}

shinyApp(ui = ui, server = server)
mat
output$suq <- renderTable({

     if (input$selectedLevels == "Technical Junior")
     {suq1<-sum(simplegap1[,input$Candidate]<0)}

     else if (input$selectedLevels == "Entry Level")
     {suq1<-sum(simplegap2[,input$Candidate]<0)}

     else if (input$selectedLevels == "Product Owner")
     {suq1<-sum(simplegap3[,input$Candidate]<0)}

     else if (input$selectedLevels == "Technical Leader")
     {suq1<-sum(simplegap4[,input$Candidate]<0)}

     else if (input$selectedLevels == "Senior Manager") 
     {suq1<-sum(simplegap5[,input$Candidate]<0)} 
     }, include.rownames = TRUE ,  bordered = TRUE ,hover = TRUE, align = "c" )
output$qsplot <- renderPlot({

      if (input$selectedLevels == "Technical Junior")
      { plot(x,-x,type = "p",main = "Qualification Space",xlim = c(0,1),ylim = c(-1,0), xlab = "SOQ",ylab = "SUQ")
       points(soq1,suq1,type="o",pch=20) }

    })
mat <- matrix(1:9, ncol = 3)

ui <- fluidPage(
  tableOutput("table1"),
  tableOutput("table2")
)

server <- function(input, output, session){
  global <- reactiveValues(mat = NULL)
  
  output$table1 <- renderTable({
    matNew <- mat
    # edit the table
    matNew[, 1] <- 1
    global$mat <- matNew
  })

  output$table2 <- renderTable({
    if(!is.null(global$mat)){
      return(global$mat)
    }
  })
}

shinyApp(ui = ui, server = server)