I am trying to create a flexible Shiny interface for discretizing continuous variables. For example, I want the user to look at `mtcars$mpg`, select `n` levels, choose the `min` and `max` for each of the `n` levels, and then give a histogram of the new discretized variable. Obviously, `cuts` is the main function for this in `R` but the main challenge is creating a flexible enough interface.

Here is what I tried:

```
server <- function(input, output) {

output$sliders <- renderUI({
    n <- input$levels
    lapply(1:n,function(i) {
      if (i==1) {
# first slider can take on any mpg
      sliderInput(paste0("slider",i),paste0("Select range for level",i),
                  min=min(mtcars$mpg),max=max(mtcars$mpg),value=max(mtcars$mpg))
      } else {
# subsequent sliders limited to values greater than previous slider's selected value 
# here is where my problems are
        sliderInput(paste0("slider",i),paste0("Select range for level",i),
                    min=as.numeric(input[,paste0("slider",i-1)]),max=max(mtcars$mpg),value=NULL)
      }
    })
  })
  output$histo <- renderPlot({
    n <- input$levels

    steps <- c(min(mtcars$mpg))
    for (i in 1:n) {
      steps <- c(steps, input[,paste0("slider",n)])
    }

    dat <- cut(mtcars$mpg,steps)
    hist(dat)

  })
}

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
      numericInput("levels", "Number of levels:", 1,min=1,max=10)
    ),
    mainPanel(h1("Discretize mpg"),uiOutput("sliders"),
              renderPlot('histo'))

)
)
shinyApp(ui = ui, server = server)

```

The issue is that I can't seem to get the subsequent `sliderInput` to render dynamically based on the value of the previous `sliderInput`. It is important that each `sliderInput` be mutally exclusive so I try to force the minimum value of each slider to be the value of the previous slider so that there can't be overlapping intervals. 

Is my approach workable or do I need to do this differently? How would I generate `n` inputs that depend on one another?

Regards