I have a dataframe and a few checkboxes that relate to columns in the dataframe. The checkboxes default is all options being selected.
**CHECKBOXES**
Name checkbox -> "Liz", "Ben"
City checkbox -> "London", "Berlin", "NYC"
**DATAFRAME**
Name City
Liz London
Liz London
Ben London
Ben London
Liz London
My problem now is when I deselect the London checkbox, the dataframe returned is empty which is the incorrect behaviour. I want to return a dataframe that corresponds to the checkboxes that are selected and if nothing is selected return an empty dataframe
My code
if (!(is.null(input$Name)) & !(is.null(input$City))) {
names <- input$Name
city <- input$City
my_df <- filter(my_df, (Name %in% names) & (City %in% city))
}
**CORRECT RETURNED DATAFRAME**
Name City
Liz London
Liz London
Ben London
Ben London
Liz London
"Liz", and "Ben" are still checked even if "London" is deselected.
Aucun commentaire:
Enregistrer un commentaire