0

Changing the y variable interactively using the following code works (with or without being embedded in a reactive environment):

library(ggvis)
library(shiny)

alt = c("Alt 1", "Alt 2", "Alt 3", "Alt 4", "Alt 5")
v2 = c(1:5)
v3 = c(6:10)
v4 = c(11:15)
v5 = c(16:20)
v6 = c(21:25)
v7 = c(26:30)

df = data.frame(alt, v2, v3, v4, v5, v6, v7)

df %>% 
  ggvis(x = ~alt, y = input_select(choices = names(df[2:7]), map = as.name)) %>% 
  layer_points()

However, if layer_points() is changed to layer_bars() it does not work and I receive the following error message in the console:

Error in .getReactiveEnvironment()$currentContext() : Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)

If I embed the code in a reactive context as the message suggests, I receive the following message in the console:

Warning: Error in : Visual property y.update is not a variable

Does anybody have an idea what is going on here?

Samuel
  • 2,895
  • 4
  • 30
  • 45
  • I don't know why `layer_bars` doesn't work like other layers, but you can work around it by following the method shown in [this answer](http://stackoverflow.com/a/31102711/2461552). Unlike that answer you will have both x and y defined in `ggvis`. Make sure *dplyr* is loaded explicitly so `filter` works correctly. – aosmith Feb 23 '17 at 16:03
  • Maybe the authors will fix it in the next release of ggvis. – Samuel Feb 24 '17 at 13:31

0 Answers0