I am trying to create an interactive visualization with the ggvis package.
Specifically, the user should be able to select which of the variables should be plotted on which axes. One way to do this was already presented in answer 2 of this question. However in this solution the axes are not labeled correctly:
E.g. in this example
library("ggvis")
library("magrittr")
sel <- input_select(names(mtcars),map=as.name)
mtcars %>% ggvis(sel,~mpg) %>% layer_points()
The y-axis has a label of "reactive_x" (x being a random number). I would now like to label the y-axis according to the currently selected variable. Adding
%>% add_axis("y",title=sel)
does not work because sel is a closure, not a character vector. Wrapping sel in as.character does not work either.
Does anybody have a solution to this problem?
Note: This would possibly easier to solve by wrapping the ggvis plot in a shiny app. However, I am not interested in such solutions as this visualization will be part of a package that I am developing.