2017-01-15 51 views
1

我想使用在光澤2個輸出的結果到另一輸出用於繪圖: 第一個輸出是soq1下面:如何保存輸出到另一個輸出在以後將其在閃亮ř

output$soq <- renderTable({ 

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

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

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

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

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

第二輸出我以後要使用的是:

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") 

後來我想使用的結果soq1和suq1另一個輸出算了一筆賬:

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) } 

    }) 

回答

0

我不知道,但我認爲你要麼尋找: 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) 

P.S: 我有點不確定,如果我得到這個問題的權利。如果你對這裏感興趣,這裏有一篇關於如何讓你很容易回答你的問題的好文章:)。 How to make a great R reproducible example?

相關問題