Is there a way to zoom in on a sliderInput for more precision in R Shiny?

Let's suppose that my min is 0 and my max is 100,000,000,000. I need precision down to 1. How can that be achieved with sliderInput?

Upvotes: 1

Views: 186

Answers (1)

HubertL
HubertL

Reputation: 19544

Your mouse (or finger) aren't precise enough to achieve this in one slider, but as proposed by @starja, you could uses several ones.

ui <- fluidPage(
  mainPanel(
    sliderInput("billions", "Billions", min = 0, max = 10^11 - 10^9, value = 0, step = 10^9, width = 1000 ),
    sliderInput("millions", "Millions", min = 0, max = 10^9 - 10^6, value = 0, step = 10^6, width = 1000 ),
    sliderInput("thousands", "Thousands", min = 0, max = 10^6 - 1000, value = 0, step = 10^3, width = 1000 ),
    sliderInput("units", "Units", min = 0, max = 10^3-1, value = 0, step = 1, width = 1000 ),
    verbatimTextOutput("result")
  )
)

server <- function(input, output, session) {
  options(scipen=999)
  output$result <- renderPrint(input$billions + input$millions + input$thousands + input$units)
}

shinyApp(ui, server)

app

One issue with this solution is that you can either have values between 0 and 99 999 999 999, or 199 999 999 999...

Upvotes: 1

Related Questions