【问题标题】:R ggvis:use input_select to set variable on x-axisR ggvis:使用 input_select 在 x 轴上设置变量
【发布时间】: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)

但我不知道如何组合这两段代码。

【问题讨论】:

    标签: r ggvis


    【解决方案1】:

    找到了!!!

    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 帮了大忙!

    【讨论】:

      猜你喜欢
      • 2015-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      • 2021-10-25
      • 1970-01-01
      • 1970-01-01
      • 2014-09-10
      相关资源
      最近更新 更多