ggpairs correlation method

Here is an example of displaying Spearman correlation values with ggpairs.

library(GGally)
#> Loading required package: ggplot2
#> Registered S3 method overwritten by 'GGally':
#>   method from   
#>   +.gg   ggplot2
DF <- data.frame(A = rnorm(20), B = rnorm(20),C = rnorm(20))
cor(DF, method = "spearman") #only for comparing to the plot values
#>            A           B           C
#> A 1.00000000  0.08721805  0.29172932
#> B 0.08721805  1.00000000 -0.07518797
#> C 0.29172932 -0.07518797  1.00000000
ggpairs(DF, 
        upper = list(continuous = wrap(ggally_cor, method = "spearman")))

Created on 2023-10-06 with reprex v2.0.2

3 Likes