Building up from your previous question you can use the min values, here slider 1 is restricted to 80 max and slider 2 restricted to 50
rm(list = ls())
library(shiny)
slider1limit <- 80
slider2limit <- 50
ui <-pageWithSidebar(
# Application title
headerPanel("Sliders should sum to 100!"),
# Sidebar with sliders whos sum should be constrained to be 100
sidebarPanel(
sliderInput("slider1", "Slider 1: ", min = 0, max = 100, value = 0, step=1),
uiOutput("slider")),
# Create table output
mainPanel(tableOutput("restable"))
)
server <- function(input, output,session) {
observeEvent(input$slider2,{
values <- min((100 - input$slider2),slider1limit)
updateSliderInput(session, "slider1", min =0,max=100, value = values)
})
output$slider <- renderUI({
values <- min((100 - input$slider1),slider2limit)
sliderInput("slider2", "Slider 2: ", min=0,max=100, value = values)
})
output$restable <- renderTable({
myvals<- c(input$slider1, input$slider2, 100-input$slider1-input$slider2)
data.frame(Names=c("Slider 1", "Slider 2", "Slider 3"),Values=myvals)
})
}
runApp(list(ui = ui, server = server))