Version Notice.

This demonstration uses an older version of {GGally}. An updated draft is required

ggpairs

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")

ggscatmat

A Traditional Scatterplot Matrix For Purely Quantitative Variables

This function makes a scatterplot matrix for quantitative variables with density plots on the diagonal and correlation printed in the upper triangle.

Usage

    
ggscatmat(data, columns = 1:ncol(data), color = NULL, alpha = 1, corMethod = "pearson")
  • data a data matrix. Should contain numerical (continuous) data.
  • columns an option to choose the column to be used in the raw dataset. Defaults to 1:ncol(data).
  • color an option to group the dataset by the factor variable and color them by different colors. Defaults to NULL.
  • alpha an option to set the transparency in scatterplots for large data. Defaults to 1.
  • corMethod method argument supplied to cor
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")