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?