应该很容易防止“伦敦”出现在页面顶部,但我找不到方法。
library(shiny)
ui <- fluidPage(
mainPanel(
mylist <- c("London","Paris"),
selectInput("s", "Select", mylist)
)
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
答案 0 :(得分:2)
将我的清单从FluidPage中移除:
library(shiny)
mylist <- c("London","Paris")
ui <- fluidPage(
mainPanel(
selectInput("s", "Select", mylist)
)
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
否则,mylist作为另一个输出(如标头)包含在mainPanel函数中。
当然,作为替代方案,您可以直接在selectInput中包含选项列表,并完全省略mylist向量:
selectInput("s", "Select", choices = c("London","Paris"))
答案 1 :(得分:0)
您可以将向量直接用于selectInput内部,例如:
library(shiny)
ui <- fluidPage(
mainPanel(
selectInput("s", "Select", choices = c("London","Paris"))
)
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
如果您必须根据选择在选项中使用一些静态验证,则可以使用以下方式:
library(shiny)
library(shinyalert)
ui <- fluidPage(
mainPanel(
useShinyalert(),
selectInput("option_select", "Select", choices = c("London"="lon","Paris"="par")),
actionButton("check_city","City Selected")
)
)
server <- function(input, output) {
observeEvent(input$check_city,{
if(input$option_select=="lon")
{
shinyalert("City Selected: London")
}
else
{
shinyalert("City Selected: Paris")
}
})
}
shinyApp(ui = ui, server = server)