Creating multivariate plots

When exploring data, we want to get a feel for the interaction of as many variables as possible. Although our display and print media can display only two dimensions, by creatively using R's plotting features, we can bring many more dimensions into play. In this recipe, we show you how you can bring up to five variables into play.

Getting ready

Read the data from file and create factors. We also attach the data to save on keystrokes as follows:

> library(ggplot2) > bike <- read.csv("daily-bike-rentals.csv") > bike$season <- factor(bike$season, levels = c(1,2,3,4), labels = c("Spring", "Summer", "Fall", "Winter")) > bike$weathersit <- factor(bike$weathersit, levels = c(1,2,3), labels = c("Clear", "Misty/cloudy", "Light ...

Get R: Recipes for Analysis, Visualization and Machine Learning 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.