This demonstration uses an older version of {GGally}. An updated draft is required
The ggpairs() function from the {GGally} package allows us to build a great scatterplot matrix. Scatterplots of each pair visualized in left side of the plot and Pearson correlation value and significance displayed on the right side.
## Registered S3 method overwritten by 'GGally':
## method from
## +.gg ggplot2
ChickWeight %>%
select(Time, weight) %>%
ggpairs()
ChickWeight %>%
select(Time, weight, Diet) %>%
ggpairs
ChickWeight %>%
select(Time, weight, Diet) %>%
ggpairs(colour = "Diet")
This function makes a scatterplot matrix for quantitative variables with density plots on the diagonal and correlation printed in the upper triangle.
ggscatmat(data, columns = 1:ncol(data), color = NULL, alpha = 1, corMethod = "pearson")
library(GGally)
data(flea)
head(flea)
## species tars1 tars2 head aede1 aede2 aede3
## 1 Concinna 191 131 53 150 15 104
## 2 Concinna 185 134 50 147 13 105
## 3 Concinna 200 137 52 144 14 102
## 4 Concinna 173 127 50 144 16 97
## 5 Concinna 171 118 49 153 13 106
## 6 Concinna 160 118 47 140 15 99
ggscatmat(flea, columns = 2:4)
ggscatmat(flea, columns = 2:4, color = "species")