使 R shiny renderPlot 对文本输入有反应
make R shiny renderPlot reactive to text input
我正在开发我的第一个 Shiny 应用程序,但我无法使我的情节的输入参数对用户在 textInput 框中的输入做出反应。
这是一个简化的代码示例,对于之前使用过 shiny 的人来说应该很熟悉。
#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" 位置的文本输入框中输入基因名称,并让 scde.test.gene.expression.difference 函数处理名称。
感谢您的帮助和耐心,我是新手。
以下解决了这个问题
#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'
将用户的反应输入打印到绘图函数中。
我正在开发我的第一个 Shiny 应用程序,但我无法使我的情节的输入参数对用户在 textInput 框中的输入做出反应。
这是一个简化的代码示例,对于之前使用过 shiny 的人来说应该很熟悉。
#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" 位置的文本输入框中输入基因名称,并让 scde.test.gene.expression.difference 函数处理名称。
感谢您的帮助和耐心,我是新手。
以下解决了这个问题
#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'
将用户的反应输入打印到绘图函数中。