Understanding basic syntax and grammar

The ggvis uses similar grammar and syntax to ggplot2, and we can use this basic syntax to create figures. In this recipe, we cover how to use ggvis syntax and grammar to build advanced plots.

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 create plots with ggvis:

  1. First, create a scatterplot by mapping Size to the x axis and Price to the y axis. Furthermore, we can assign different colors or shapes to points with different statuses:
    > house %>% ggvis(~Size, ~Price, fill=~Status, size=10, shape=~Status) %>% layer_points()
    

    Figure 11: A scatterplot ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.