Home > front end >  Create connection between numericInput and function in a Shiny app
Create connection between numericInput and function in a Shiny app

Time:03-15

The code below generates a map with clusters. The cluster number will depend on the k variable that is inside my function. To get this k value, I use the Weighted Sum Method (WSM) calculation. Note that for this calculation it is necessary to choose the weights of the criteria, in my case there are only two. Therefore, k can vary depending on the chosen weights. In my function I manually put (weights <- c(0.5,0.5)). However, I would like to put the weights from the two numericInput I created. So how to do this? Another thing, in this case, the map is only generated after the weights are selected.

This question can help: enter image description here

CodePudding user response:

Why don't you redesign your function to this:

function.cl<-function(weights){
...
}

and in the reactive call on the server side you do this:

Modelcl<-reactive({
    function.cl(weights=c(input$weight1, input$weight2))
  })
  • Related