我想獲取從 selectInput() 中選擇的專案。但是,似乎只有第一項可以傳輸到 server()。用戶界面:
sidebarLayout(
sidebarPanel(width = 4,
selectInput("cell_marker_density_surv", "Cell type", choices = cell_list,
selected = colnames(density)[1:3], multiple = TRUE),
textOutput("warning_density_roc_1"),
),
mainPanel(width = 8,
)
)
服務器()
warning_density_roc_1_output <- reactive({
a = input$cell_marker_density_surv
paste0(input$cell_marker_density_surv, collapse = ",")
})
output$warning_density_roc_1 <- renderText(warning_density_roc_1_output())
正如我們所見,即使在默認情況下,也只顯示了第一項。

舊答案:
也許這會有所幫助,我使用mpg資料集作為虛擬資料。
library(shiny)
mpg <- ggplot2::mpg
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
width = 4,
textOutput("warning_density_roc_1"),
selectInput("cell_marker_density_surv", "Cell type",
choices = names(mpg),
selected = names(mpg)[1:6], multiple = TRUE
)
),
mainPanel(width = 8, )
)
)
server <- function(input, output, session) {
warning_density_roc_1_output <- reactive({
if (length(input$cell_marker_density_surv) > 5) {
"Warning, more than five items selected."
}
})
output$warning_density_roc_1 <- renderText(warning_density_roc_1_output())
}
shinyApp(ui, server)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/390450.html
上一篇:RDBI系結變數性能
下一篇:洗掉在R中有重復的行
