R Shiny - Numeric Input without Selectors

前端 未结 2 2018
梦如初夏
梦如初夏 2021-01-22 05:38

Is there a way to have a numeric input without the selectors? Every time the slider is pressed, all calculation in my app occur, so it could get choked up by a user easily. Poss

相关标签:
2条回答
  • 2021-01-22 06:22

    You could use a textInput and have a reactive() that converts it to numeric so, for example, if numInput is the name of your textInput:

    In server.R:

    numConv <- reactive({as.numeric(input$numInput)})
    

    Then anywhere that was referring to input$numInput change to numConv(). You can add any code you want the reactive, so you could do additional checks to make sure that the user is entering a valid input before it triggers all the other calculations in your app.

    0 讨论(0)
  • 2021-01-22 06:23

    In your ui.R file, use inputs like the following:

    shinyUI(pageWithSidebar(
        sidebarPanel(
            textInput("text", "Enter Text:", "Default Text"),
            numericInput("num1", "Please Enter a Number:", 42)
          )
    ))
    

    Hope that helps.

    0 讨论(0)
提交回复
热议问题