2017-02-26 39 views
1

我正在處理我的第一個Shiny應用程序,並且無法爲我的情節制作一個輸入參數,而無法響應用戶輸入到textInput框中。讓R有光澤renderPlot與文本輸入無關

這是一個瘦身的代碼示例,這應該看起來很熟悉那些以前曾經與之合作過的人。

#ui.R 
library(shiny) 
shinyUI(fluidPage(
    titlePanel("Shiny App"), 

    sidebarLayout(
    sidebarPanel(h2("Menu"), 

mainPanel(h1("Main"), 
tabPanel("Differential Expression", 
     column(6, 
       p("Input your gene of interest below"), 
       textInput(uiOutput("GeneVariable"), label = h4("Gene of interest"), 
       value = "Gjb2"), 
       submitButton("Submit")), 
     plotOutput("plot2"), 

    ) 
) 
)) 

#server.R 
shinyServer(function(input, output) { 

output$plot2 <- renderPlot({ 
    scde.test.gene.expression.difference("GeneVariable", 
             models=o.ifm, counts=cd, prior=o.prior) 
    }) 

GeneVariable <- reactive({ ###I don't know what to put here##### 
    }) 
}) 

我需要用戶能夠輸入基因名稱到與textInput箱中的「GeneVariable」位置,並且具有由所述scde.test.gene.expression.difference函數處理名稱。

感謝您的幫助和耐心,我對此很感興趣。

+0

是否有一些代碼缺失? – BigDataScientist

+0

是的,我試圖只複製代碼的相關部分。 – Paul

回答

1

下努力解決這個問題

#ui.R 
library(shiny) 
shinyUI(fluidPage(
    titlePanel("Shiny App"), 

    sidebarLayout(
    sidebarPanel(h2("Menu"), 

mainPanel(h1("Main"), 
tabPanel("Differential Expression", 
     column(6, 
       p("Input your gene of interest below"), 
       textInput("input$GeneVariable"), label = h4("Gene of interest"), 
       value = "Gjb2"), 
       submitButton("Submit")), 
     plotOutput("plot2"), 

    ) 
) 
)) 

#server.R 
shinyServer(function(input, output) { 

output$plot2 <- renderPlot({ 
    scde.test.gene.expression.difference(input$`input$GeneVariable`, 
             models=o.ifm, counts=cd, prior=o.prior) 
    }) 

GeneVariable <- reactive({input$GeneVariable}) 
    }) 
}) 

關鍵是使用input$'input$GeneVariable'將用戶的無功輸入打印到繪圖函數中。