With the GGally package, we can create a multivariate plot of an entire data frame. It's pretty useful to have the big picture of a dataset. Ggpairs integrates with the other ggplot functions and automatically selects a visualization for each segment of the grid. We will create one with the previously viewed auto dataset. If you have not imported it, perform the following commands:
> auto <- read.csv("auto-mpg.csv", stringsAsFactors=FALSE) > auto$cylinders <- factor(auto$cylinders,labels=c("3cyl","4cyl", "5cyl","6cyl","8cyl"))
Now use the ggpairs() function to create the plot; we will only select mpg, cylinders, displacement, and horsepower:
Look at the results in the following ...