Pairwise Scatter Plot Among Multiple Variables

Learn how to create a pairwise scatter plot among multiple variables

How do we create a pairwise scatter plot among multiple variables?

The R base has the pairs() function that can produce rather primitive pairwise scatterplots. The ggscatmat() function in the GGally package can produce much more—a figure that includes pairwise scatter plots, density plots, and correlation coefficients. It helps us explore the relationships among the variables, in terms of correlation strength and direction, any non-linear pattern, variable distribution, outliers, and possible coding errors. The R code is as follows. As a caveat, the ggscatmat() function only works for numeric data; with categorical data, the ggpairs() function can be used.

Get hands-on with 1200+ tech skills courses.