Reputation: 1711
I currently have some data for which I'd love to be able to add an interactive multiple checkbox option that lets the user select which area of the body they want to view data from. At the moment it looks like this:
library(ggvis)
areas_data %>%
ggvis(~Bacilli, ~Actinobacteria) %>%
filter(area %in% c("Skin", "Oral", "Gut") ) %>%
layer_points( fill = ~area, size := 50, opacity := 0.5)
I can't figure out how to change the filter line so that it will interactively change the data you're viewing. I've tried inserting input_checkboxgroup into the filter line, but keep receiving an error about how the comparison is only possible for atomic and list types. I've tried a lot of different variants of the line, an example being:
filter(area %in% input_checkboxgroup(c("Skin" = "Skin", "Oral" = "Oral", "Gut" = "Gut") ) ) %>%
Thanks!
Upvotes: 1
Views: 1043
Reputation: 531
This same question was asked and fully answered over in the ggvis google discussion group (basically, you need to use 'eval' inside the 'filter' call).
Posting the link to the answer (from the person who wrote the R package no less) here for future reference:
https://groups.google.com/forum/#!topic/ggvis/AJZCdjFcNaE
Upvotes: 1