Exploring the mtcars data set

Have you ever wondered whether there is a clear correlation between the gas consumption of a car and its weight? To answer this question, we first have to load the dplyr and ggvis packages.

library(dplyr)
library(ggvis)
mtcars %>%
  group_by(factor(cyl)) %>%
  ggvis(~mpg, ~wt, fill = ~cyl) %>%
  layer_points()

The ggvis plot gives us a nice visualization of the mtcars data set: