The output of checkboxGroupInput
is a vector.
It is intended to be used when you may want to select more than one element at the same time.
To avoid confusion (and avoid letting our reactive have a run every time you select a box) it works best in conjunction with an action button:
- once you have done your selection (one or many more items);
- you can push the action button for execution. This makes sure that you process the user's selection only when the user is ready for it.
Also, sometime I prefer not to use a list, but just a simple vector, e.g.:
checkboxGroupInput("checkGroup", label = h2("Data Sets"),
choices = c("Accounts Created", "Comments",
"Submissions", "Votes"),
selected = NULL)
Then you can process on the server side the character vector, that will have the different value, e.g. input$checkGroup
may be equal to c("Accounts Created", "Comments")
if the first two boxes have been selected, and so on.
Perhaps the code I posted in reply to the following SO question may be of help R Shiny observeEvent issues
Please take into consideration that if many elements will be selected, you need to have a proper treatment pipeline. For example, if
(or switch
) only works for one elements at the time, and if you want to scan the output vector one element at the time, it works greatly. If you r treatment is more complex you need to think it through carefully.
Please do not hesitate to ask for more if it is not clear.