您是否知道在ggplot2中以交互方式选择构面的方法? 我试过操纵和复选框,没有成功......
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")
)
答案 0 :(得分:1)
你可以试试,
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")
)