0

This code generates the chart I want, but I would like to pass the content of input_radiobuttons as vertical axis label in place of the random string reactive_931110099.

enter image description here

library(ggvis)
mtcars %>% ggvis(x = ~wt, y= input_radiobuttons( 
     choices = c("mpg" = 'mpg', "disp" = 'disp'),
      label = "Y-axis",
      map = as.name)
     )
    layer_densities(
      adjust = input_slider(.1, 2, value = 1, step = .1, label = "Bandwidth adjustment"),
      kernel = input_select(
        c("Gaussian" = "gaussian",
          "Epanechnikov" = "epanechnikov",
          "Rectangular" = "rectangular",
          "Triangular" = "triangular",
          "Biweight" = "biweight",
          "Cosine" = "cosine",
          "Optcosine" = "optcosine"),
        label = "Kernel")
    )
Dambo
  • 3,318
  • 5
  • 30
  • 79
  • Does not seem possible at this point -- see http://stackoverflow.com/questions/32464822/how-do-i-control-the-axis-labels-on-a-ggvis-plot-where-the-variables-to-be-plott – Weihuang Wong Oct 29 '16 at 19:56

1 Answers1

1
mtcars %>% ggvis(x = ~wt, y= input_radiobuttons( 
     choices = c("mpg" = 'mpg', "disp" = 'disp'),
      label = "Y-axis",
      map = as.name)
     ) %>%
   add_axis("y", title = "Pick Your Own Label", title_offset = 50)
    layer_densities(
      adjust = input_slider(.1, 2, value = 1, step = .1, label = "Bandwidth adjustment"),
      kernel = input_select(
        c("Gaussian" = "gaussian",
          "Epanechnikov" = "epanechnikov",
          "Rectangular" = "rectangular",
          "Triangular" = "triangular",
          "Biweight" = "biweight",
          "Cosine" = "cosine",
          "Optcosine" = "optcosine"),
        label = "Kernel")
    )

enter image description here

Cyrus Mohammadian
  • 4,982
  • 6
  • 33
  • 62