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:
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:
We see a strong linear relationship between WEIGHT_1
and WEIGHT_2
, and curved relationships between those variables and HEIGHT
.