Adding interactivity to a ggvis plot

One of the most attractive features of ggvis is that it can be used to create an interactive web form. This allows the user to subset the data, or even change the visual properties of the plot, through interacting with the web form. In this recipe, we introduce how to add interactivity to a ggvis object.

Getting ready

Ensure you have installed and loaded ggvis into your R session. Also, you need to complete the previous steps by storing house in your R environment.

How to do it…

Please perform the following steps to add interactivity to ggvis:

  1. First, make a bar plot with a drop-down menu and color options:
    > house %>% 
    +     ggvis(~Status, ~Price, fill:= input_select(c("red","blue"), label="Fill Color")) %>% 
    + layer_bars() ...

Get R for Data Science Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.