【发布时间】:2018-07-12 02:05:26
【问题描述】:
在这个 ggvis 示例中,有没有办法过滤图例以反映输入选择,例如未选择“z”时仅显示“x”和“y”? This would be especially useful when the choices are extensive.
library(tidyverse)
library(ggvis)
data_df <- tibble(
name = factor(c("x", "x", "x", "y", "y", "y", "z", "z", "z")),
quant = c(7, 8, 7, 8, 8, 8, 9, 9, 9),
year = factor(c(2014, 2015, 2016, 2014, 2015, 2016, 2014, 2015, 2016))
)
data_df %>%
ggvis(~ year, ~ quant, stroke = ~ name) %>%
filter(name %in% eval(
input_select(
choices = levels(data_df$name),
selected = c("x", "y"),
selectize = TRUE,
multiple = TRUE
)
)) %>%
layer_lines()
【问题讨论】: