r - Reactivity while using ggvis/shiny -


i new shiny/ggvis , want create scatter plot allows user select x , y dropdown. have attempted feat may times no avail , appreciate help. please see code below.

library(shiny) library(ggvis) library(dplyr)  # define user interface    shinyui(pagewithsidebar(     # add title page      headerpanel(       h1("test header panel!")),       sidebarpanel(       uioutput("ggvis_ui"),       sliderinput(inputid = "size",label = "area",10, 1000, value = c(10)),       selectinput(inputid = "yaxis",label = "y variable", c("wt","drat")),             selectinput(inputid = "xaxis",label = " x variable", c("cyl", "am","gear"))),        mainpanel(       h1("please review chart below showing nothing!"),        ggvisoutput("ggvis")        )     )    ) 

server.r

# create server.r      shinyserver(function(input, output, session) {        # reactive expression wrapper input$size       input_size <- reactive(input$size)       input_xaxis <- reactive(input$xaxis)       input_yaxis <- reactive(input$yaxis)        # reactive expression wrapper input$size         mtcars %>%          ggvis(x =input_xaxis, y = input_yaxis, size := input_size) %>%         layer_points() %>%         bind_shiny("ggvis", "ggvis_ui")       }) 

the 2 things missing making plot reactive , using prop setting properties when variables names strings.

the following change server code returns reactive graphic:

plot = reactive({     mtcars %>%     ggvis(prop("x", as.name(input_xaxis())),           prop("y", as.name(input_yaxis())),           size := input_size) %>%     layer_points()     })  plot %>%     bind_shiny("ggvis", "ggvis_ui") 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo