我学会了在Rstudio闪亮示例(http://shiny.rstudio.com/gallery/update-input-demo.html)的闪亮应用程序中使用动态选择输入。一切似乎都没问题,但发生了一个错误。我测试了很多,发现错误是由于所使用的动态选择输入(server.R中的观察功能)。但我无法弄清楚如何解决它。任何帮助将不胜感激。谢谢! 为了节省空间,一些代码未显示。闪亮的动态选择输入错误
server.R
load("./data/genomicVar.RData")
load("./data/geneInfo.RData")
fetchInfoByMsu <- function(locus="") {...}
fetchSnpByMsu <- function(locus="") {...}
fetchIndelByMsu <- function(locus="") {...}
fetchSvByMsu <- function(locus="") {...}
fetchExpByMsu <- function(locus="") {...}
fetchInfoByBin <- function(binNumber="") {...}
fetchGeneByBin <- function(binNumber="") {...}
shinyServer(function(input, output, session) {
output$mytable1 = renderDataTable({...})
output$mytable2 = renderDataTable({...})
output$mytable3 = renderDataTable({...})
output$mytable4 = renderDataTable({...})
output$mytable5 = renderDataTable({...})
output$mytable6 = renderDataTable({...})
output$mytable7 = renderDataTable({...})
observe({
c_bin <- input$bin
c_gene <- fetchGeneByBin(input$bin)
c_gene <- c_gene$locus
# Select input
s_options <- list()
for (i in c_gene) {
s_options[[i]] <- i
}
# Change values for input$inSelect
updateSelectInput(session, "inSelect",
choices = s_options,
selected = c_gene[1]
)
})
output$mytable8 = renderDataTable({...})
output$mytable9 = renderDataTable({...})
output$mytable10 = renderDataTable({...})
output$mytable11 = renderDataTable({...})
output$mytable12 = renderDataTable({...})
})
UI.R
shinyUI(fluidPage(
fluidRow(
absolutePanel(
textInput("msu", label = h4("MSU genomic locus:"),
value = "LOC_Os07g15770"),
tabsetPanel(
tabPanel(strong('Information'), dataTableOutput("mytable1")),
tabPanel(strong('SNP'), dataTableOutput("mytable2")),
tabPanel(strong('Indels'), dataTableOutput("mytable3")),
tabPanel(strong('SVs'), dataTableOutput("mytable4")),
tabPanel(strong('Expression'), dataTableOutput("mytable5"))
),
br(),
p(HTML("<b><div style='background-color:#FADDF2;border:1px solid
blue;'></div></b>")),
textInput("bin", label = h4("Bin ID:"), value = "Bin1078"),
tabsetPanel(
tabPanel(strong('Information'), dataTableOutput("mytable6")),
tabPanel(strong('Gene'), dataTableOutput("mytable7"))
),
wellPanel(
selectInput("inSelect", strong("Select gene:"),
c("gene 1" = "option1",
"gene 2" = "option2"))
),
tabsetPanel(
tabPanel(strong('Information'), dataTableOutput("mytable8")),
tabPanel(strong('SNP'), dataTableOutput("mytable9")),
tabPanel(strong('Indels'), dataTableOutput("mytable10")),
tabPanel(strong('SVs'), dataTableOutput("mytable11")),
tabPanel(strong('Expression'), dataTableOutput("mytable12"))
),
br(),
p(HTML("<b><div style='background-color:#FADDF2;border:1px solid
blue;'></div></b>")),
right=5, left=10
)
)
))
尝试使's_options'反应性表达。 – 2014-09-01 08:13:52
什么是错误信息?另外,请尝试使用'uiOutput'? – zx8754 2014-09-01 08:20:45