R ggvis:use input_select 在x轴上设置变量
R ggvis:use input_select to set variable on x-axis
我正在尝试使用 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 的 帮助很大!
我正在尝试使用 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 的