I am trying to create 2 checkbox input group based on the user input, so that I can run a logic to plot it against each other. Now Ideally IF the user selects 2 options in group 1 it shouldn't appear in group 2 of the checkboxgroup. How do I implement this?
The Column names, when created by user is appearing properly in the checkbox group as expected, but it is not being dynamic. That is when One option is selected it is not disappearing from the second group
So when 2 options are selected in the first group, It should disappear from the second option
Providing the UI part
uiOutput("ui_costs_choices"),
uiOutput("ui_benefits_choices")
Providing the server part
#Defining the ui_costs_choices
output$ui_costs_choices <- renderUI({
req(rv$df)
checkboxGroupInput("Costs", "Select the cost criteria:", choices = names(rv$df))
})
#Defining the ui_benefits_choices
output$ui_benefits_choices <- renderUI({
req(rv$df)
checkboxGroupInput("Benefits", "Select the Benefits criteria:", choices = names(rv$df))
})
observeEvent(input$Costs, {
req(rv$df)
# Get the names of the columns in rv$df
all_choices <- names(rv$df)
# Remove the ones that are already selected as costs
benefit_choices <- setdiff(all_choices, input$costs)
# Update the benefit checkboxGroupInput with the remaining choices
updateCheckboxGroupInput(session, "Benefits", choices = benefit_choices)
})
observeEvent(input$Benefits, {
req(rv$df)
# Get the names of the columns in rv$df
all_choices <- names(rv$df)
# Remove the ones that are already selected as benefits
cost_choices <- setdiff(all_choices, input$benefits)
# Update the cost checkboxGroupInput with the remaining choices
updateCheckboxGroupInput(session, "Costs", choices = cost_choices)
})
rv is a reactive object which contains the user entered values in the table in rv$df
Aucun commentaire:
Enregistrer un commentaire