我正在尝试使用input_select在ggvis图中设置x变量。假设以下基本图:
mtcars %>%
ggvis(~wt, ~mpg) %>%
layer_points()
我读到here,我应该使用此表达式:
prop(x = input_select(c("disp", "wt")), constant = FALSE)
但是我不知道如何组合这两段代码。
答案 0 :(得分:0)
找到了!!!
xVariables = c("hp","disp")
mtcars %>%
ggvis(prop("x", input_select(xVariables, map=as.name), scale = TRUE), y=~mpg) %>%
scale_numeric("x", domain = c(NA, NA), clamp = TRUE, nice = TRUE) %>%
scale_numeric("y", domain = c(NA, NA), clamp = TRUE, nice = TRUE) %>%
add_axis("x", title = "I don't know how this make this dynamic.") %>%
layer_points()
(不幸的是,我无法弄清楚如何动态调整xlabel。如果有人知道,补码将非常受欢迎。)
Jonathan H的This post有很多帮助!