【发布时间】:2019-09-04 03:25:56
【问题描述】:
我正在尝试使用 input_select 在 ggvis 图中设置 x 变量。假设以下基图:
mtcars %>%
ggvis(~wt, ~mpg) %>%
layer_points()
我读到here 我应该使用这个表达式:
prop(x = input_select(c("disp", "wt")), constant = FALSE)
但我不知道如何组合这两段代码。
【问题讨论】:
我正在尝试使用 input_select 在 ggvis 图中设置 x 变量。假设以下基图:
mtcars %>%
ggvis(~wt, ~mpg) %>%
layer_points()
我读到here 我应该使用这个表达式:
prop(x = input_select(c("disp", "wt")), constant = FALSE)
但我不知道如何组合这两段代码。
【问题讨论】:
找到了!!!
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 帮了大忙!
【讨论】: