【问题标题】:Past Text for multiple Select Input (R; Shiny)多个选择输入的过去文本(R;闪亮)
【发布时间】:2018-07-13 04:30:04
【问题描述】:

我正在开发一个闪亮的应用程序,并在下面创建了我的问题的简化版本。 Pretty much I want to have a input select of different options (A,B,C,D) and when any or all of these options are selected then prints out different texts.目前,如果我选择所有选项,则只有“Your Idael A Value is”帖子。

library(shiny) 
shinyServer( function(input, output) {
  output$whatever<-renderText( {
    if( input$test=="a") {
      ("Your ideal A value is")
    }
    else if (input$test=="b") {
      ("Your ideal B value is:")
    }
    else if (input$test=="c") {
      ("Your ideal C value is:")
    }
    else if(input$test=="D") {
      ("Your idea D value is:")
    }
  }
  )
}

)

    library(shiny)

   shinyUI(fluidPage(
   headerPanel(title="pratice"),
   sidebarLayout(
   sidebarPanel(
   selectInput("test",label="Test",multiple = TRUE, 
   choices=list("a","b","c","d")
   )),
   mainPanel(
  textOutput("whatever")
  )
  )
  )
  )

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    if 语句在遇到 valide 语句时立即停止。

    这里不需要if,你可以简单地将输入值粘贴在一起:

    library(shiny) 
    server <- shinyServer( function(input, output) {
      output$whatever<-renderText( {
        vals <- paste(input$test, collapse = " ")
        paste("Your ideal(s) value(s) are", vals)
    
      }
      )
    }
    
    )
    
    ui <- shinyUI(fluidPage(
      headerPanel(title="pratice"),
      sidebarLayout(
        sidebarPanel(
          selectInput("test",label="Test",multiple = TRUE, 
                      choices=list("a","b","c","d"), 
          )),
        mainPanel(
          textOutput("whatever")
        )
      )
    )
    )
    
    shinyApp(ui, server)
    

    【讨论】:

      【解决方案2】:

      你可以使用:

       selectizeInput(inputId, label, choices, selected = NULL, multiple = FALSE,
                 options = NULL) ## and switch multiple to True
      

      【讨论】:

      • 你雅各布是个天才
      猜你喜欢
      • 2018-10-09
      • 2021-07-16
      • 1970-01-01
      • 2016-03-16
      • 2020-08-01
      • 1970-01-01
      • 2015-01-19
      • 2018-08-02
      相关资源
      最近更新 更多