Reputation: 1451
Would you know a way to interactively select facets in ggplot2? I tried manipulate and checkbox, without success...
library(ggplot2)
library(manipulate)
manipulate(
ggplot(subset(iris, Species %in% c(cb1, cb2, cb3)), aes(x = Petal.Width, y = Petal.Length)) +
facet_grid(. ~ Species) +
geom_point(),
cb1 = checkbox(TRUE, "setosa"),
cb2 = checkbox(TRUE, "versicolor"),
cb3 = checkbox(TRUE, "virginica")
)
Upvotes: 0
Views: 75
Reputation: 288
You could try,
vector=c("setosa","versicolor","virginica")
manipulate(ggplot(subset(iris, Species %in% vector[c(cb1, cb2, cb3)]), aes(x = Petal.Width, y = Petal.Length)) +
facet_grid(. ~ Species) +
geom_point(),
cb1 = checkbox(TRUE, "setosa"),
cb2 = checkbox(TRUE, "versicolor"),
cb3 = checkbox(TRUE, "virginica")
)
Upvotes: 1