Using pairs.panel() to look at (visualize) correlations between variables
Within the R ecosystem, there are different packages offering ways to represent correlations between variables in a dataset.
In a way, the powerful plot()
function, as seen in the previous recipe, can also be useful for correlation spotting, particularly when plotting all variables against one another (refer to the previous recipe for more details).
Nevertheless, among different alternatives, the one I think may give you a quicker and deeper understanding of the relationship between your data is the pairs.panels()
function provided by the psych
package by William Revelle.
Getting ready
In order to use the pairs.panels()
function, we first need to install and load the psych
package:
install.packages("psych") library(psych)
To test the pairs.panels()
functionality, we will use the Iris dataset.
The Iris dataset is one of most used datasets in R tutorials and learning sessions, and it is derived from a 1936 paper...