0

I am trying to set the x variable in a ggvis plot using input_select. Suppose the following base plot:

mtcars %>% 
  ggvis(~wt, ~mpg) %>%
  layer_points()

I read here that I should use this expression:

prop(x = input_select(c("disp", "wt")), constant = FALSE)

But I don't know how to combine these two pieces of code.

Frank
  • 541
  • 1
  • 6
  • 18

1 Answers1

0

Found it !!!

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()

(Unfortuntaly I could not figure out how to adjust the xlabel dynamically. If anyone knows, complementing would be very welcome.)

This post from Jonathan H helped a lot!

Frank
  • 541
  • 1
  • 6
  • 18