2

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. Possibly use a text input and cast it as numeric maybe?

Any other ideas?

A_Skelton73
  • 1,150
  • 4
  • 12
  • 23

2 Answers2

8

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.

Eric
  • 962
  • 8
  • 12
-3

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.

nfmcclure
  • 3,011
  • 3
  • 24
  • 40