我學會了在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