title: Make condition for weight equal to a specific value in a shiny app
body: <p>The code below works fine. Basically, a clustered map is generated. To know the cluster number, I use the <code>TOPSIS</code> multicriteria method. For the <code>TOPSIS</code> method, it is necessary to choose criteria weights, which usually range from 0 to 1. Since I have two criteria, I created two <code>numericInput</code> to generate the weights. If you test the APP you will see that it works, the only case that doesn't work is if you put <code>weights1</code> equal to 1. Therefore, I would like to put some condition or something, that when this happens, consider, weight 1 = 0.9 and not equal to 1.</p>
  <pre><code>library(shiny)
  library(rdist)
  library(geosphere)
  library(shinythemes)
  library(leaflet)
  library(topsis)
  
  function.cl&lt;-function(df,k,weights){
    
    #database df
    df&lt;-structure(list(Properties = c(1,2,3,4,5,6,7), 
                       Latitude = c(-23.8, -23.8, -23.9, -23.9, -23.9,-23.4,-23.5), 
                       Longitude = c(-49.6, -49.3, -49.4, -49.8, -49.6,-49.4,-49.2), 
                       Coverage = c (1526, 2350, 3526, 2469, 1285, 2433, 2456),
                       Production = c(526, 350, 526, 469, 285, 433, 456)), class = &quot;data.frame&quot;, row.names = c(NA, -7L))
  
    #Topsis
    df1 &lt;- df[c(4:5)]
    df1&lt;-data.matrix(df1)
    i &lt;- c(&quot;-&quot;, &quot;+&quot;) 
    #weights &lt;- c(0.3,0.7) 
    scaled2&lt;-topsis(df1, weights, i)
    scaled2$rank &lt;- rank(-scaled2$score,ties.method= &quot;first&quot;)
    colnames(scaled2)&lt;-c(&quot;Alternatives&quot;,&quot;score&quot;,&quot;Ranking&quot;)
    
    k&lt;-subset(scaled2, Ranking==2)$Alternatives #cluster number
    
    #clusters
    coordinates&lt;-df[c(&quot;Latitude&quot;,&quot;Longitude&quot;)]
    d&lt;-as.dist(distm(coordinates[,2:1]))
    fit.average&lt;-hclust(d,method=&quot;average&quot;) 
    clusters&lt;-cutree(fit.average, k) 
    nclusters&lt;-matrix(table(clusters))  
    df$cluster &lt;- clusters 
    df1&lt;-df[c(&quot;Latitude&quot;,&quot;Longitude&quot;)]
    
    
    #Color and Icon for map
    ai_colors &lt;-c(&quot;red&quot;,&quot;gray&quot;,&quot;blue&quot;,&quot;orange&quot;,&quot;green&quot;,&quot;beige&quot;)
    
    clust_colors &lt;- ai_colors[df$cluster]
    icons &lt;- awesomeIcons(
      icon = 'ios-close',
      iconColor = 'black',
      library = 'ion',
      markerColor =  clust_colors)
    
    # Map for all clusters:
    m1&lt;-leaflet(df1) %&gt;% addTiles() %&gt;%
      addMarkers(~Longitude, ~Latitude) %&gt;%
      addAwesomeMarkers(lat=~df$Latitude, lng = ~df$Longitude, icon=icons, label=~as.character(df$cluster)) %&gt;% 
      addLegend( position = &quot;topright&quot;, title=&quot;Cluster&quot;, colors = ai_colors[1:max(df$cluster)],labels = unique(df$cluster))
    
    plot1&lt;-m1
    
    return(list(
      &quot;Plot1&quot; = plot1
    ))
  }
  
  ui &lt;- bootstrapPage(
    navbarPage(theme = shinytheme(&quot;flatly&quot;), collapsible = TRUE,
               &quot;Cl&quot;, 
               tabPanel(&quot;Solution&quot;,
                        sidebarLayout(
                          sidebarPanel(
                            
                            numericInput(&quot;weights1&quot;, label = h5(&quot;Choose the weight 1&quot;),min = 0, max = 1, value = NA, step = 0.1),
                            numericInput(&quot;weights2&quot;, label = h5(&quot;Choose the weight 2&quot;),min = 0, max = 1, value = NA, step = 0.1)
                          ),
                          mainPanel(
                            tabsetPanel(      
                              tabPanel(&quot;Solution&quot;, (leafletOutput(&quot;Leaf1&quot;,width = &quot;95%&quot;, height = &quot;600&quot;)))))
                          
                        ))))
  
  server &lt;- function(input, output, session) {
    
    Modelcl&lt;-reactive({
      function.cl(df,k,weights=c(input$weights1, input$weights2))
    })
    
    output$Leaf1 &lt;- renderLeaflet({
      req(weights=c(input$weights1, input$weights2))
      Modelcl()[[1]]
    })
    
    observeEvent(input$weights1, {
      freezeReactiveValue(input, &quot;weights2&quot;)
      updateNumericInput(session, 'weights2',
                         value = 1 - input$weights1)
    })
    
    
  }
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/RApiJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RApiJ.png" alt="enter image description here" /></a></p>