O'Reilly logo

R Graph Essentials by David Alexander Lillis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating scatterplot matrices

Scatterplot matrices of bivariate data are helpful to identify relationships between variables in a dataset. We can create scatterplot matrices using pairs() and the tilde sign, along with plus signs that instruct R to include the desired variables:

pairs(~WEIGHT_1 + WEIGHT_2 + HEIGHT, data=T, 
main="Scatterplot Matrix of Medical Data")

This syntax gives the following matrix:

Creating scatterplot matrices

If we want a smooth curve (LOWESS) in each bivariate plot, we include the argument panel=panel.smooth:

pairs(~WEIGHT_1 + WEIGHT_2 + HEIGHT, data=T, 
main="Scatterplot Matrix of Medical Data", panel = panel.smooth)

The matrix obtained is as follows: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required