Javascript 条件面板以多个选择输入为条件
我想在conditionalPanel上设置一个条件,只要selectInput包含1,conditionalPanel就会显示 我不熟悉JavaScript,有人能帮忙吗Javascript 条件面板以多个选择输入为条件,javascript,r,shiny,shinydashboard,Javascript,R,Shiny,Shinydashboard,我想在conditionalPanel上设置一个条件,只要selectInput包含1,conditionalPanel就会显示 我不熟悉JavaScript,有人能帮忙吗 library(shiny) library(shinydashboard) ui <- function() { dashboardPage(dashboardHeader(), dashboardSidebar( selectInput(in
library(shiny)
library(shinydashboard)
ui <- function() {
dashboardPage(dashboardHeader(),
dashboardSidebar(
selectInput(inputId = "month", label = "Month", choices = 1:12, multiple = TRUE)
),
dashboardBody(
conditionalPanel(condition = "input.month == '1'", h1("success"))
),
skin = "blue")
}
server <- function(input, output, session) {
}
shinyApp(ui, server)
库(闪亮)
图书馆(shinydashboard)
ui如果我理解正确,您的问题是--您希望打印“成功”,直到选择“1”。。。如果这是您的问题,您可以在下面尝试
library(shiny)
library(stringr)
library(shinydashboard)
ui <- function() {
dashboardPage(dashboardHeader(),
dashboardSidebar(
selectInput(inputId = "month", label = "Month", choices = 1:12, multiple = TRUE)
),
dashboardBody(
#conditionalPanel(condition = "input.month == '1'", h1("success"))
uiOutput("output")
),
skin = "blue")
}
server <- function(input, output, session) {
output$output<-renderUI({
if("TRUE" %in% str_detect(input$month,'1')==TRUE)
{
h1("Success")
}
else
{
returnValue()
}
})
}
shinyApp(ui, server)
库(闪亮)
图书馆(stringr)
图书馆(shinydashboard)
ui给定一个JavaScript数组arr
,arr
中元素x
的索引由arr.indexOf(x)
给出。如果x
不属于arr
,则arr.indexOf(x)
返回-1
所以你要找的条件是
condition = "input.month.indexOf('1') > -1"