2017-02-26 8 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##### 
    }) 
}) 

私は「GeneVariable」の位置にあるにtextInputボックスに遺伝子名を入力することが可能と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'を使用していました。

関連する問題