通过排除从另一个 selectInput() 选择的值来更新 selectInput()
Update selectInput() by exlcluding values selected from another selectInput()
在下面的 shiny
应用程序中,我希望将第一个 selectInput()
的选定值从第二个 selectInput()
加上我已经排除的一列中排除。
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
selectInput("col","Pick a column to change its name",
choices = colnames(iris)[-c(1)]),
uiOutput("second")
),
dashboardBody(
)
)
server <- function(input, output) {
output$second<-renderUI({
selectInput("col2","Pick a column to change its name",
choices = colnames(iris)[-c(1,input$col)])
})
}
shinyApp(ui, server)
也许尝试分两步删除名称
output$second<-renderUI({
ex_names <- colnames(iris)[-1]
ex_names <- ex_names[! ex_names %in% input$col]
selectInput("col2","Pick a column to change its name", choices = ex_names)
})
在下面的 shiny
应用程序中,我希望将第一个 selectInput()
的选定值从第二个 selectInput()
加上我已经排除的一列中排除。
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
selectInput("col","Pick a column to change its name",
choices = colnames(iris)[-c(1)]),
uiOutput("second")
),
dashboardBody(
)
)
server <- function(input, output) {
output$second<-renderUI({
selectInput("col2","Pick a column to change its name",
choices = colnames(iris)[-c(1,input$col)])
})
}
shinyApp(ui, server)
也许尝试分两步删除名称
output$second<-renderUI({
ex_names <- colnames(iris)[-1]
ex_names <- ex_names[! ex_names %in% input$col]
selectInput("col2","Pick a column to change its name", choices = ex_names)
})