闪亮的验证+ eventReactive - 不起作用?

时间:2017-06-03 03:52:33

标签: r shiny

Shiny validate似乎不适用于eventReactive:

shinyServer(function(input, output, session) {

  observe({
      switch <- input$switch

      if (switch == "hide") {
        # https://shiny.rstudio.com/gallery/update-input-demo.html
        updateNumericInput(session, "n", "X", min = 0, max = 100, value = 0)
      }

  })

  ntext <- eventReactive(input$goButton, {
    validate(
      need(input$switch != "hide", "Please select a data set")
    )

    input$n
  })

  output$text <- renderText({
    ntext()
  })
})


shinyUI(pageWithSidebar(
  headerPanel("Click the button"),
  sidebarPanel(

    radioButtons(
        inputId = "switch",
        label = "Select hide or show:",
        choices = c(
            "Show" = "show",
            "Hide" = "hide"
        ),
        selected = NULL,
        inline = FALSE
    ),

    conditionalPanel(
        condition = "input.switch == 'show'",
        numericInput("n", "N:", min = 0, max = 100, value = 0)
    ),

    actionButton("goButton", "Go!")
  ),
  mainPanel(
    textOutput("text")
  )
))

任何想法如何将它与eventReactive一起使用?

0 个答案:

没有答案
相关问题