R Shiny - digital input without selectors

Is there a way to have numeric input without selectors? Every time the slider is clicked, all the calculations in my application happen, so it can easily choke on the user. Maybe use text input and enter it as numeric?

Any other ideas?

+1


source to share


2 answers


You can use textInput and have reactive()

that converts it to numeric, for example if numInput

is the name of your textInput:

In server.R:



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

      

Then, anywhere in relation to input$numInput

, will change to numConv()

. You can add whatever code you want to be responsive, so you can perform additional checks to make sure the user is entering valid input before they initiate all other calculations in your application.

+5


source


In your ui.R file use the following values:

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

      



Hope it helps.

-3


source







All Articles